diff --git a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/AbstractServiceMessageSource.java b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/AbstractServiceMessageSource.java index ec075b1..ab9b240 100644 --- a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/AbstractServiceMessageSource.java +++ b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/AbstractServiceMessageSource.java @@ -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; @@ -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(); @@ -85,6 +87,7 @@ protected Locale getInternalLocale() { return null; } + @Nonnull @Override public final Locale getDefaultLocale() { if (defaultLocale != null) { @@ -93,6 +96,7 @@ public final Locale getDefaultLocale() { return ServiceMessageSource.super.getDefaultLocale(); } + @Nonnull @Override public final List getSupportedLocales() { if (supportedLocales != null) { diff --git a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/CompositeServiceMessageSource.java b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/CompositeServiceMessageSource.java index 8e46454..6f233a5 100644 --- a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/CompositeServiceMessageSource.java +++ b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/CompositeServiceMessageSource.java @@ -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; @@ -109,7 +108,7 @@ public void setServiceMessageSources(List 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 @@ -182,7 +181,7 @@ private ServiceMessageSource getFirstServiceMessageSource() { private void iterate(Class serviceMessageSourceType, Consumer consumer) { this.serviceMessageSources.stream() - .filter(serviceMessageSource -> serviceMessageSourceType.isInstance(serviceMessageSource)) + .filter(serviceMessageSourceType::isInstance) .map(serviceMessageSourceType::cast) .forEach(consumer); } diff --git a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/EmptyServiceMessageSource.java b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/EmptyServiceMessageSource.java index 7a68e6f..6fde1c8 100644 --- a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/EmptyServiceMessageSource.java +++ b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/EmptyServiceMessageSource.java @@ -1,5 +1,6 @@ package io.microsphere.i18n; +import javax.annotation.Nonnull; import java.util.Locale; /** @@ -28,6 +29,7 @@ public String getMessage(String code, Locale locale, Object... args) { return null; } + @Nonnull @Override public Locale getLocale() { return getDefaultLocale(); diff --git a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/PropertiesResourceServiceMessageSource.java b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/PropertiesResourceServiceMessageSource.java index d7d1588..ffb3d10 100644 --- a/microsphere-i18n-core/src/main/java/io/microsphere/i18n/PropertiesResourceServiceMessageSource.java +++ b/microsphere-i18n-core/src/main/java/io/microsphere/i18n/PropertiesResourceServiceMessageSource.java @@ -26,6 +26,7 @@ public PropertiesResourceServiceMessageSource(String source) { super(source); } + @SuppressWarnings({"unchecked", "rawtypes"}) @Override protected final Map loadMessages(String resource) { Map messages = null; diff --git a/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/DelegatingServiceMessageSource.java b/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/DelegatingServiceMessageSource.java index e4d9292..8c8d966 100644 --- a/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/DelegatingServiceMessageSource.java +++ b/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/DelegatingServiceMessageSource.java @@ -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); diff --git a/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/context/I18nApplicationListener.java b/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/context/I18nApplicationListener.java index 959c24b..fd6c912 100644 --- a/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/context/I18nApplicationListener.java +++ b/microsphere-i18n-spring/src/main/java/io/microsphere/i18n/spring/context/I18nApplicationListener.java @@ -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);