Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix annotation #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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