Skip to content

Commit

Permalink
Merge pull request #1 from walklown/fix/fix-error-annotation
Browse files Browse the repository at this point in the history
fix annotation
  • Loading branch information
mercyblitz authored Apr 25, 2024
2 parents 27035dc + e4932ca commit 9ac8578
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -69,6 +70,7 @@ public final String getMessage(String code, Locale locale, Object... args) {
return message;
}

@Nonnull
@Override
public final Locale getLocale() {
Locale locale = getInternalLocale();
Expand All @@ -85,6 +87,7 @@ protected Locale getInternalLocale() {
return null;
}

@Nonnull
@Override
public final Locale getDefaultLocale() {
if (defaultLocale != null) {
Expand All @@ -93,6 +96,7 @@ public final Locale getDefaultLocale() {
return ServiceMessageSource.super.getDefaultLocale();
}

@Nonnull
@Override
public final List<Locale> getSupportedLocales() {
if (supportedLocales != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void init() {
forEach(this.serviceMessageSources, ServiceMessageSource::init);
}

@Nonnull
@Override
public String getMessage(String code, Locale locale, Object... args) {
String message = null;
Expand Down Expand Up @@ -109,7 +108,7 @@ public void setServiceMessageSources(List<? extends ServiceMessageSource> servic
oldServiceMessageSources.clear();
}
this.serviceMessageSources = newServiceMessageSources;
logger.debug("Source '{}' sets ServiceMessageSource list, original : {} , sorted : {}", serviceMessageSources, newServiceMessageSources);
logger.debug("Source '{}' sets ServiceMessageSource list, sorted : {}", serviceMessageSources, newServiceMessageSources);
}

@Override
Expand Down Expand Up @@ -182,7 +181,7 @@ private ServiceMessageSource getFirstServiceMessageSource() {

private <T> void iterate(Class<T> serviceMessageSourceType, Consumer<T> consumer) {
this.serviceMessageSources.stream()
.filter(serviceMessageSource -> serviceMessageSourceType.isInstance(serviceMessageSource))
.filter(serviceMessageSourceType::isInstance)
.map(serviceMessageSourceType::cast)
.forEach(consumer);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.microsphere.i18n;

import javax.annotation.Nonnull;
import java.util.Locale;

/**
Expand Down Expand Up @@ -28,6 +29,7 @@ public String getMessage(String code, Locale locale, Object... args) {
return null;
}

@Nonnull
@Override
public Locale getLocale() {
return getDefaultLocale();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public PropertiesResourceServiceMessageSource(String source) {
super(source);
}

@SuppressWarnings({"unchecked", "rawtypes"})
@Override
protected final Map<String, String> loadMessages(String resource) {
Map<String, String> messages = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void afterPropertiesSet() throws Exception {
init();
}

@NonNull
@Override
public String getMessage(String code, Locale locale, Object... args) {
return this.delegate.getMessage(code, locale, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void initializeServiceMessageSource(ApplicationContext context) {
}


@SuppressWarnings("unchecked")
private void initializeAcceptHeaderLocaleResolver(ApplicationContext context) {
if (ACCEPT_HEADER_LOCALE_RESOLVER_CLASS == null) {
logger.debug("The class '{}' was not found!", ACCEPT_HEADER_LOCALE_RESOLVER_CLASS_NAME);
Expand Down

0 comments on commit 9ac8578

Please sign in to comment.