Restore static final formatting

Restore static final constants to upper case formatting.

See gh-10457
pull/11378/head
Phillip Webb 7 years ago
parent 6a55623910
commit 2c429ba77d

@ -16,8 +16,9 @@
package org.springframework.boot.cli; package org.springframework.boot.cli;
import java.util.Arrays; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.springframework.boot.cli.command.Command; import org.springframework.boot.cli.command.Command;
@ -39,14 +40,25 @@ import org.springframework.boot.cli.command.test.TestCommand;
*/ */
public class DefaultCommandFactory implements CommandFactory { public class DefaultCommandFactory implements CommandFactory {
private static final List<Command> defaultCommands = Arrays.<Command>asList( private static final List<Command> DEFAULT_COMMANDS;
new VersionCommand(), new RunCommand(), new TestCommand(), new GrabCommand(),
new JarCommand(), new WarCommand(), new InstallCommand(), static {
new UninstallCommand(), new InitCommand()); ArrayList<Command> defaultCommands = new ArrayList<Command>();
defaultCommands.add(new VersionCommand());
defaultCommands.add(new RunCommand());
defaultCommands.add(new TestCommand());
defaultCommands.add(new GrabCommand());
defaultCommands.add(new JarCommand());
defaultCommands.add(new WarCommand());
defaultCommands.add(new InstallCommand());
defaultCommands.add(new UninstallCommand());
defaultCommands.add(new InitCommand());
DEFAULT_COMMANDS = Collections.unmodifiableList(defaultCommands);
}
@Override @Override
public Collection<Command> getCommands() { public Collection<Command> getCommands() {
return defaultCommands; return DEFAULT_COMMANDS;
} }
} }

@ -42,7 +42,7 @@ import org.springframework.core.env.PropertySource;
@Order(Ordered.LOWEST_PRECEDENCE) @Order(Ordered.LOWEST_PRECEDENCE)
public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor { public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor {
private static final Map<String, Object> properties; private static final Map<String, Object> PROPERTIES;
static { static {
Map<String, Object> devToolsProperties = new HashMap<String, Object>(); Map<String, Object> devToolsProperties = new HashMap<String, Object>();
@ -58,7 +58,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
devToolsProperties.put("spring.mvc.log-resolved-exception", "true"); devToolsProperties.put("spring.mvc.log-resolved-exception", "true");
devToolsProperties.put("server.jsp-servlet.init-parameters.development", "true"); devToolsProperties.put("server.jsp-servlet.init-parameters.development", "true");
devToolsProperties.put("spring.reactor.stacktrace-mode.enabled", "true"); devToolsProperties.put("spring.reactor.stacktrace-mode.enabled", "true");
properties = Collections.unmodifiableMap(devToolsProperties); PROPERTIES = Collections.unmodifiableMap(devToolsProperties);
} }
@Override @Override
@ -66,7 +66,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
SpringApplication application) { SpringApplication application) {
if (isLocalApplication(environment) && canAddProperties(environment)) { if (isLocalApplication(environment) && canAddProperties(environment)) {
PropertySource<?> propertySource = new MapPropertySource("refresh", PropertySource<?> propertySource = new MapPropertySource("refresh",
properties); PROPERTIES);
environment.getPropertySources().addLast(propertySource); environment.getPropertySources().addLast(propertySource);
} }
} }

@ -228,14 +228,14 @@ class ImportsContextCustomizer implements ContextCustomizer {
private static final Class<?>[] NO_IMPORTS = {}; private static final Class<?>[] NO_IMPORTS = {};
private static final Set<AnnotationFilter> annotationFilters; private static final Set<AnnotationFilter> ANNOTATION_FILTERS;
static { static {
Set<AnnotationFilter> filters = new HashSet<AnnotationFilter>(); Set<AnnotationFilter> filters = new HashSet<AnnotationFilter>();
filters.add(new JavaLangAnnotationFilter()); filters.add(new JavaLangAnnotationFilter());
filters.add(new KotlinAnnotationFilter()); filters.add(new KotlinAnnotationFilter());
filters.add(new SpockAnnotationFilter()); filters.add(new SpockAnnotationFilter());
annotationFilters = Collections.unmodifiableSet(filters); ANNOTATION_FILTERS = Collections.unmodifiableSet(filters);
} }
private final Set<Object> key; private final Set<Object> key;
@ -274,7 +274,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
} }
private boolean isIgnoredAnnotation(Annotation annotation) { private boolean isIgnoredAnnotation(Annotation annotation) {
for (AnnotationFilter annotationFilter : annotationFilters) { for (AnnotationFilter annotationFilter : ANNOTATION_FILTERS) {
if (annotationFilter.isIgnored(annotation)) { if (annotationFilter.isIgnored(annotation)) {
return true; return true;
} }

@ -76,7 +76,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
WRAPPER_TYPES = Collections.unmodifiableMap(types); WRAPPER_TYPES = Collections.unmodifiableMap(types);
} }
private static final Map<Class<?>, Object> defaultTypeValues; private static final Map<Class<?>, Object> DEFAULT_TYPE_VALUES;
static { static {
Map<Class<?>, Object> values = new HashMap<Class<?>, Object>(); Map<Class<?>, Object> values = new HashMap<Class<?>, Object>();
@ -85,16 +85,16 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
values.put(Short.class, (short) 0); values.put(Short.class, (short) 0);
values.put(Integer.class, 0); values.put(Integer.class, 0);
values.put(Long.class, (long) 0); values.put(Long.class, (long) 0);
defaultTypeValues = Collections.unmodifiableMap(values); DEFAULT_TYPE_VALUES = Collections.unmodifiableMap(values);
} }
private static final Map<String, Object> wellKnownStaticFinals; private static final Map<String, Object> WELL_KNOWN_STATIC_FINALS;
static { static {
Map<String, Object> values = new HashMap<String, Object>(); Map<String, Object> values = new HashMap<String, Object>();
values.put("Boolean.TRUE", true); values.put("Boolean.TRUE", true);
values.put("Boolean.FALSE", false); values.put("Boolean.FALSE", false);
wellKnownStaticFinals = Collections.unmodifiableMap(values); WELL_KNOWN_STATIC_FINALS = Collections.unmodifiableMap(values);
} }
private final Map<String, Object> fieldValues = new HashMap<String, Object>(); private final Map<String, Object> fieldValues = new HashMap<String, Object>();
@ -115,7 +115,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
private Object getValue(VariableTree variable) throws Exception { private Object getValue(VariableTree variable) throws Exception {
ExpressionTree initializer = variable.getInitializer(); ExpressionTree initializer = variable.getInitializer();
Class<?> wrapperType = WRAPPER_TYPES.get(variable.getType()); Class<?> wrapperType = WRAPPER_TYPES.get(variable.getType());
Object defaultValue = defaultTypeValues.get(wrapperType); Object defaultValue = DEFAULT_TYPE_VALUES.get(wrapperType);
if (initializer != null) { if (initializer != null) {
return getValue(initializer, defaultValue); return getValue(initializer, defaultValue);
} }
@ -148,7 +148,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
return this.staticFinals.get(expression.toString()); return this.staticFinals.get(expression.toString());
} }
if (expression.getKind().equals("MEMBER_SELECT")) { if (expression.getKind().equals("MEMBER_SELECT")) {
return wellKnownStaticFinals.get(expression.toString()); return WELL_KNOWN_STATIC_FINALS.get(expression.toString());
} }
return defaultValue; return defaultValue;
} }

@ -123,7 +123,7 @@ public final class Layouts {
*/ */
public static class War implements Layout { public static class War implements Layout {
private static final Map<LibraryScope, String> scopeDestinations; private static final Map<LibraryScope, String> SCOPE_DESTINATIONS;
static { static {
Map<LibraryScope, String> map = new HashMap<LibraryScope, String>(); Map<LibraryScope, String> map = new HashMap<LibraryScope, String>();
@ -131,7 +131,7 @@ public final class Layouts {
map.put(LibraryScope.CUSTOM, "WEB-INF/lib/"); map.put(LibraryScope.CUSTOM, "WEB-INF/lib/");
map.put(LibraryScope.RUNTIME, "WEB-INF/lib/"); map.put(LibraryScope.RUNTIME, "WEB-INF/lib/");
map.put(LibraryScope.PROVIDED, "WEB-INF/lib-provided/"); map.put(LibraryScope.PROVIDED, "WEB-INF/lib-provided/");
scopeDestinations = Collections.unmodifiableMap(map); SCOPE_DESTINATIONS = Collections.unmodifiableMap(map);
} }
@Override @Override
@ -141,7 +141,7 @@ public final class Layouts {
@Override @Override
public String getLibraryDestination(String libraryName, LibraryScope scope) { public String getLibraryDestination(String libraryName, LibraryScope scope) {
return scopeDestinations.get(scope); return SCOPE_DESTINATIONS.get(scope);
} }
@Override @Override

@ -42,7 +42,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
*/ */
public class ArtifactsLibraries implements Libraries { public class ArtifactsLibraries implements Libraries {
private static final Map<String, LibraryScope> scopes; private static final Map<String, LibraryScope> SCOPES;
static { static {
Map<String, LibraryScope> libraryScopes = new HashMap<String, LibraryScope>(); Map<String, LibraryScope> libraryScopes = new HashMap<String, LibraryScope>();
@ -50,7 +50,7 @@ public class ArtifactsLibraries implements Libraries {
libraryScopes.put(Artifact.SCOPE_RUNTIME, LibraryScope.RUNTIME); libraryScopes.put(Artifact.SCOPE_RUNTIME, LibraryScope.RUNTIME);
libraryScopes.put(Artifact.SCOPE_PROVIDED, LibraryScope.PROVIDED); libraryScopes.put(Artifact.SCOPE_PROVIDED, LibraryScope.PROVIDED);
libraryScopes.put(Artifact.SCOPE_SYSTEM, LibraryScope.PROVIDED); libraryScopes.put(Artifact.SCOPE_SYSTEM, LibraryScope.PROVIDED);
scopes = Collections.unmodifiableMap(libraryScopes); SCOPES = Collections.unmodifiableMap(libraryScopes);
} }
private final Set<Artifact> artifacts; private final Set<Artifact> artifacts;
@ -70,7 +70,7 @@ public class ArtifactsLibraries implements Libraries {
public void doWithLibraries(LibraryCallback callback) throws IOException { public void doWithLibraries(LibraryCallback callback) throws IOException {
Set<String> duplicates = getDuplicates(this.artifacts); Set<String> duplicates = getDuplicates(this.artifacts);
for (Artifact artifact : this.artifacts) { for (Artifact artifact : this.artifacts) {
LibraryScope scope = scopes.get(artifact.getScope()); LibraryScope scope = SCOPES.get(artifact.getScope());
if (scope != null && artifact.getFile() != null) { if (scope != null && artifact.getFile() != null) {
String name = getFileName(artifact); String name = getFileName(artifact);
if (duplicates.contains(name)) { if (duplicates.contains(name)) {

@ -49,7 +49,7 @@ import org.springframework.boot.ansi.AnsiStyle;
@ConverterKeys({ "clr", "color" }) @ConverterKeys({ "clr", "color" })
public final class ColorConverter extends LogEventPatternConverter { public final class ColorConverter extends LogEventPatternConverter {
private static final Map<String, AnsiElement> elements; private static final Map<String, AnsiElement> ELEMENTS;
static { static {
Map<String, AnsiElement> ansiElements = new HashMap<String, AnsiElement>(); Map<String, AnsiElement> ansiElements = new HashMap<String, AnsiElement>();
@ -60,17 +60,17 @@ public final class ColorConverter extends LogEventPatternConverter {
ansiElements.put("blue", AnsiColor.BLUE); ansiElements.put("blue", AnsiColor.BLUE);
ansiElements.put("magenta", AnsiColor.MAGENTA); ansiElements.put("magenta", AnsiColor.MAGENTA);
ansiElements.put("cyan", AnsiColor.CYAN); ansiElements.put("cyan", AnsiColor.CYAN);
elements = Collections.unmodifiableMap(ansiElements); ELEMENTS = Collections.unmodifiableMap(ansiElements);
} }
private static final Map<Integer, AnsiElement> levels; private static final Map<Integer, AnsiElement> LEVELS;
static { static {
Map<Integer, AnsiElement> ansiLevels = new HashMap<Integer, AnsiElement>(); Map<Integer, AnsiElement> ansiLevels = new HashMap<Integer, AnsiElement>();
ansiLevels.put(Level.FATAL.intLevel(), AnsiColor.RED); ansiLevels.put(Level.FATAL.intLevel(), AnsiColor.RED);
ansiLevels.put(Level.ERROR.intLevel(), AnsiColor.RED); ansiLevels.put(Level.ERROR.intLevel(), AnsiColor.RED);
ansiLevels.put(Level.WARN.intLevel(), AnsiColor.YELLOW); ansiLevels.put(Level.WARN.intLevel(), AnsiColor.YELLOW);
levels = Collections.unmodifiableMap(ansiLevels); LEVELS = Collections.unmodifiableMap(ansiLevels);
} }
private final List<PatternFormatter> formatters; private final List<PatternFormatter> formatters;
@ -101,7 +101,7 @@ public final class ColorConverter extends LogEventPatternConverter {
} }
PatternParser parser = PatternLayout.createPatternParser(config); PatternParser parser = PatternLayout.createPatternParser(config);
List<PatternFormatter> formatters = parser.parse(options[0]); List<PatternFormatter> formatters = parser.parse(options[0]);
AnsiElement element = (options.length == 1 ? null : elements.get(options[1])); AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1]));
return new ColorConverter(formatters, element); return new ColorConverter(formatters, element);
} }
@ -125,7 +125,7 @@ public final class ColorConverter extends LogEventPatternConverter {
AnsiElement element = this.styling; AnsiElement element = this.styling;
if (element == null) { if (element == null) {
// Assume highlighting // Assume highlighting
element = levels.get(event.getLevel().intLevel()); element = LEVELS.get(event.getLevel().intLevel());
element = (element == null ? AnsiColor.GREEN : element); element = (element == null ? AnsiColor.GREEN : element);
} }
appendAnsiString(toAppendTo, buf.toString(), element); appendAnsiString(toAppendTo, buf.toString(), element);

@ -38,7 +38,7 @@ import org.springframework.boot.ansi.AnsiStyle;
*/ */
public class ColorConverter extends CompositeConverter<ILoggingEvent> { public class ColorConverter extends CompositeConverter<ILoggingEvent> {
private static final Map<String, AnsiElement> elements; private static final Map<String, AnsiElement> ELEMENTS;
static { static {
Map<String, AnsiElement> ansiElements = new HashMap<String, AnsiElement>(); Map<String, AnsiElement> ansiElements = new HashMap<String, AnsiElement>();
@ -49,24 +49,24 @@ public class ColorConverter extends CompositeConverter<ILoggingEvent> {
ansiElements.put("blue", AnsiColor.BLUE); ansiElements.put("blue", AnsiColor.BLUE);
ansiElements.put("magenta", AnsiColor.MAGENTA); ansiElements.put("magenta", AnsiColor.MAGENTA);
ansiElements.put("cyan", AnsiColor.CYAN); ansiElements.put("cyan", AnsiColor.CYAN);
elements = Collections.unmodifiableMap(ansiElements); ELEMENTS = Collections.unmodifiableMap(ansiElements);
} }
private static final Map<Integer, AnsiElement> levels; private static final Map<Integer, AnsiElement> LEVELS;
static { static {
Map<Integer, AnsiElement> ansiLevels = new HashMap<Integer, AnsiElement>(); Map<Integer, AnsiElement> ansiLevels = new HashMap<Integer, AnsiElement>();
ansiLevels.put(Level.ERROR_INTEGER, AnsiColor.RED); ansiLevels.put(Level.ERROR_INTEGER, AnsiColor.RED);
ansiLevels.put(Level.WARN_INTEGER, AnsiColor.YELLOW); ansiLevels.put(Level.WARN_INTEGER, AnsiColor.YELLOW);
levels = Collections.unmodifiableMap(ansiLevels); LEVELS = Collections.unmodifiableMap(ansiLevels);
} }
@Override @Override
protected String transform(ILoggingEvent event, String in) { protected String transform(ILoggingEvent event, String in) {
AnsiElement element = elements.get(getFirstOption()); AnsiElement element = ELEMENTS.get(getFirstOption());
if (element == null) { if (element == null) {
// Assume highlighting // Assume highlighting
element = levels.get(event.getLevel().toInteger()); element = LEVELS.get(event.getLevel().toInteger());
element = (element == null ? AnsiColor.GREEN : element); element = (element == null ? AnsiColor.GREEN : element);
} }
return toAnsiString(in, element); return toAnsiString(in, element);

@ -66,23 +66,23 @@ public class ApplicationPidFileWriter
private static final String DEFAULT_FILE_NAME = "application.pid"; private static final String DEFAULT_FILE_NAME = "application.pid";
private static final List<Property> fileProperties; private static final List<Property> FILE_PROPERTIES;
static { static {
List<Property> properties = new ArrayList<Property>(); List<Property> properties = new ArrayList<Property>();
properties.add(new SpringProperty("spring.pid.", "file")); properties.add(new SpringProperty("spring.pid.", "file"));
properties.add(new SpringProperty("spring.", "pidfile")); properties.add(new SpringProperty("spring.", "pidfile"));
properties.add(new SystemProperty("PIDFILE")); properties.add(new SystemProperty("PIDFILE"));
fileProperties = Collections.unmodifiableList(properties); FILE_PROPERTIES = Collections.unmodifiableList(properties);
} }
private static final List<Property> failOnWriteErrorProperties; private static final List<Property> FAIL_ON_WRITE_ERROR_PROPERTIES;
static { static {
List<Property> properties = new ArrayList<Property>(); List<Property> properties = new ArrayList<Property>();
properties.add(new SpringProperty("spring.pid.", "fail-on-write-error")); properties.add(new SpringProperty("spring.pid.", "fail-on-write-error"));
properties.add(new SystemProperty("PID_FAIL_ON_WRITE_ERROR")); properties.add(new SystemProperty("PID_FAIL_ON_WRITE_ERROR"));
failOnWriteErrorProperties = Collections.unmodifiableList(properties); FAIL_ON_WRITE_ERROR_PROPERTIES = Collections.unmodifiableList(properties);
} }
private static final AtomicBoolean created = new AtomicBoolean(false); private static final AtomicBoolean created = new AtomicBoolean(false);
@ -153,7 +153,7 @@ public class ApplicationPidFileWriter
private void writePidFile(SpringApplicationEvent event) throws IOException { private void writePidFile(SpringApplicationEvent event) throws IOException {
File pidFile = this.file; File pidFile = this.file;
String override = getProperty(event, fileProperties); String override = getProperty(event, FILE_PROPERTIES);
if (override != null) { if (override != null) {
pidFile = new File(override); pidFile = new File(override);
} }
@ -162,7 +162,7 @@ public class ApplicationPidFileWriter
} }
private boolean failOnWriteError(SpringApplicationEvent event) { private boolean failOnWriteError(SpringApplicationEvent event) {
String value = getProperty(event, failOnWriteErrorProperties); String value = getProperty(event, FAIL_ON_WRITE_ERROR_PROPERTIES);
return (value == null ? false : Boolean.parseBoolean(value)); return (value == null ? false : Boolean.parseBoolean(value));
} }

@ -43,14 +43,14 @@ import org.springframework.web.context.WebApplicationContext;
class ServletComponentRegisteringPostProcessor class ServletComponentRegisteringPostProcessor
implements BeanFactoryPostProcessor, ApplicationContextAware { implements BeanFactoryPostProcessor, ApplicationContextAware {
private static final List<ServletComponentHandler> handlers; private static final List<ServletComponentHandler> HANDLERS;
static { static {
List<ServletComponentHandler> servletComponentHandlers = new ArrayList<ServletComponentHandler>(); List<ServletComponentHandler> servletComponentHandlers = new ArrayList<ServletComponentHandler>();
servletComponentHandlers.add(new WebServletHandler()); servletComponentHandlers.add(new WebServletHandler());
servletComponentHandlers.add(new WebFilterHandler()); servletComponentHandlers.add(new WebFilterHandler());
servletComponentHandlers.add(new WebListenerHandler()); servletComponentHandlers.add(new WebListenerHandler());
handlers = Collections.unmodifiableList(servletComponentHandlers); HANDLERS = Collections.unmodifiableList(servletComponentHandlers);
} }
private final Set<String> packagesToScan; private final Set<String> packagesToScan;
@ -78,7 +78,7 @@ class ServletComponentRegisteringPostProcessor
for (BeanDefinition candidate : componentProvider for (BeanDefinition candidate : componentProvider
.findCandidateComponents(packageToScan)) { .findCandidateComponents(packageToScan)) {
if (candidate instanceof ScannedGenericBeanDefinition) { if (candidate instanceof ScannedGenericBeanDefinition) {
for (ServletComponentHandler handler : handlers) { for (ServletComponentHandler handler : HANDLERS) {
handler.handle(((ScannedGenericBeanDefinition) candidate), handler.handle(((ScannedGenericBeanDefinition) candidate),
(BeanDefinitionRegistry) this.applicationContext); (BeanDefinitionRegistry) this.applicationContext);
} }
@ -97,7 +97,7 @@ class ServletComponentRegisteringPostProcessor
false); false);
componentProvider.setEnvironment(this.applicationContext.getEnvironment()); componentProvider.setEnvironment(this.applicationContext.getEnvironment());
componentProvider.setResourceLoader(this.applicationContext); componentProvider.setResourceLoader(this.applicationContext);
for (ServletComponentHandler handler : handlers) { for (ServletComponentHandler handler : HANDLERS) {
componentProvider.addIncludeFilter(handler.getTypeFilter()); componentProvider.addIncludeFilter(handler.getTypeFilter());
} }
return componentProvider; return componentProvider;

Loading…
Cancel
Save