Cleanup and format code

This commit is contained in:
Phillip Webb
2017-03-06 16:44:31 -08:00
parent c7b46e4d1c
commit d8f827d224
649 changed files with 1922 additions and 2003 deletions

View File

@@ -385,7 +385,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
}
private Map<String, Object> getAnnotationElementValues(AnnotationMirror annotation) {
Map<String, Object> values = new LinkedHashMap<String, Object>();
Map<String, Object> values = new LinkedHashMap<>();
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
.getElementValues().entrySet()) {
values.put(entry.getKey().getSimpleName().toString(),

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ import org.springframework.boot.configurationprocessor.metadata.ItemMetadata;
*/
public class MetadataCollector {
private final List<ItemMetadata> metadataItems = new ArrayList<ItemMetadata>();
private final List<ItemMetadata> metadataItems = new ArrayList<>();
private final ProcessingEnvironment processingEnvironment;
@@ -47,7 +47,7 @@ public class MetadataCollector {
private final TypeUtils typeUtils;
private final Set<String> processedSourceTypes = new HashSet<String>();
private final Set<String> processedSourceTypes = new HashSet<>();
/**
* Creates a new {@code MetadataProcessor} instance.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,13 +49,13 @@ class TypeElementMembers {
private final TypeUtils typeUtils;
private final Map<String, VariableElement> fields = new LinkedHashMap<String, VariableElement>();
private final Map<String, VariableElement> fields = new LinkedHashMap<>();
private final Map<String, ExecutableElement> publicGetters = new LinkedHashMap<String, ExecutableElement>();
private final Map<String, ExecutableElement> publicGetters = new LinkedHashMap<>();
private final Map<String, List<ExecutableElement>> publicSetters = new LinkedHashMap<String, List<ExecutableElement>>();
private final Map<String, List<ExecutableElement>> publicSetters = new LinkedHashMap<>();
private final Map<String, Object> fieldValues = new LinkedHashMap<String, Object>();
private final Map<String, Object> fieldValues = new LinkedHashMap<>();
private final FieldValuesParser fieldValuesParser;
@@ -107,7 +107,7 @@ class TypeElementMembers {
List<ExecutableElement> matchingSetters = this.publicSetters
.get(propertyName);
if (matchingSetters == null) {
matchingSetters = new ArrayList<ExecutableElement>();
matchingSetters = new ArrayList<>();
this.publicSetters.put(propertyName, matchingSetters);
}
TypeMirror paramType = method.getParameters().get(0).asType();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import javax.lang.model.type.TypeMirror;
*/
class TypeExcludeFilter {
private final Set<String> excludes = new HashSet<String>();
private final Set<String> excludes = new HashSet<>();
TypeExcludeFilter() {
add("com.zaxxer.hikari.IConnectionCustomizer");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ class TypeUtils {
private static final Map<TypeKind, Class<?>> PRIMITIVE_WRAPPERS;
static {
Map<TypeKind, Class<?>> wrappers = new HashMap<TypeKind, Class<?>>();
Map<TypeKind, Class<?>> wrappers = new HashMap<>();
wrappers.put(TypeKind.BOOLEAN, Boolean.class);
wrappers.put(TypeKind.BYTE, Byte.class);
wrappers.put(TypeKind.CHAR, Character.class);
@@ -56,7 +56,7 @@ class TypeUtils {
private static final Map<String, TypeKind> WRAPPER_TO_PRIMITIVE;
static {
Map<String, TypeKind> primitives = new HashMap<String, TypeKind>();
Map<String, TypeKind> primitives = new HashMap<>();
for (Map.Entry<TypeKind, Class<?>> entry : PRIMITIVE_WRAPPERS.entrySet()) {
primitives.put(entry.getValue().getName(), entry.getKey());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +75,7 @@ class ExpressionTree extends ReflectionWrapper {
public List<? extends ExpressionTree> getArrayExpression() throws Exception {
if (this.newArrayTreeType.isAssignableFrom(getInstance().getClass())) {
List<?> elements = (List<?>) this.arrayValueMethod.invoke(getInstance());
List<ExpressionTree> result = new ArrayList<ExpressionTree>();
List<ExpressionTree> result = new ArrayList<>();
if (elements == null) {
return result;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
private static final Map<String, Class<?>> WRAPPER_TYPES;
static {
Map<String, Class<?>> types = new HashMap<String, Class<?>>();
Map<String, Class<?>> types = new HashMap<>();
types.put("boolean", Boolean.class);
types.put(Boolean.class.getName(), Boolean.class);
types.put("byte", Byte.class);
@@ -79,7 +79,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
private static final Map<Class<?>, Object> DEFAULT_TYPE_VALUES;
static {
Map<Class<?>, Object> values = new HashMap<Class<?>, Object>();
Map<Class<?>, Object> values = new HashMap<>();
values.put(Boolean.class, false);
values.put(Byte.class, (byte) 0);
values.put(Short.class, (short) 0);
@@ -91,15 +91,15 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
private static final Map<String, Object> WELL_KNOWN_STATIC_FINALS;
static {
Map<String, Object> values = new HashMap<String, Object>();
Map<String, Object> values = new HashMap<>();
values.put("Boolean.TRUE", true);
values.put("Boolean.FALSE", false);
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<>();
private final Map<String, Object> staticFinals = new HashMap<String, Object>();
private final Map<String, Object> staticFinals = new HashMap<>();
@Override
public void visitVariable(VariableTree variable) throws Exception {

View File

@@ -40,7 +40,7 @@ public class ConfigurationMetadata {
static {
List<Character> chars = Arrays.asList('-', '_');
SEPARATORS = Collections.unmodifiableSet(new HashSet<Character>(chars));
SEPARATORS = Collections.unmodifiableSet(new HashSet<>(chars));
}
private final Map<String, List<ItemMetadata>> items;
@@ -48,13 +48,13 @@ public class ConfigurationMetadata {
private final Map<String, List<ItemHint>> hints;
public ConfigurationMetadata() {
this.items = new LinkedHashMap<String, List<ItemMetadata>>();
this.hints = new LinkedHashMap<String, List<ItemHint>>();
this.items = new LinkedHashMap<>();
this.hints = new LinkedHashMap<>();
}
public ConfigurationMetadata(ConfigurationMetadata metadata) {
this.items = new LinkedHashMap<String, List<ItemMetadata>>(metadata.items);
this.hints = new LinkedHashMap<String, List<ItemHint>>(metadata.hints);
this.items = new LinkedHashMap<>(metadata.items);
this.hints = new LinkedHashMap<>(metadata.hints);
}
/**
@@ -135,7 +135,7 @@ public class ConfigurationMetadata {
private <K, V> void add(Map<K, List<V>> map, K key, V value) {
List<V> values = map.get(key);
if (values == null) {
values = new ArrayList<V>();
values = new ArrayList<>();
map.put(key, values);
}
values.add(value);
@@ -198,7 +198,7 @@ public class ConfigurationMetadata {
}
private static <T extends Comparable<T>> List<T> flattenValues(Map<?, List<T>> map) {
List<T> content = new ArrayList<T>();
List<T> content = new ArrayList<>();
for (List<T> values : map.values()) {
content.addAll(values);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,10 +44,9 @@ public class ItemHint implements Comparable<ItemHint> {
public ItemHint(String name, List<ValueHint> values, List<ValueProvider> providers) {
this.name = toCanonicalName(name);
this.values = (values != null ? new ArrayList<ValueHint>(values)
: new ArrayList<ValueHint>());
this.providers = (providers != null ? new ArrayList<ValueProvider>(providers)
: new ArrayList<ValueProvider>());
this.values = (values != null ? new ArrayList<>(values) : new ArrayList<>());
this.providers = (providers != null ? new ArrayList<>(providers)
: new ArrayList<>());
}
private String toCanonicalName(String name) {

View File

@@ -32,7 +32,7 @@ import org.json.JSONObject;
@SuppressWarnings("rawtypes")
class JSONOrderedObject extends JSONObject {
private Set<String> keys = new LinkedHashSet<String>();
private Set<String> keys = new LinkedHashSet<>();
@Override
public JSONObject put(String key, Object value) throws JSONException {

View File

@@ -118,14 +118,14 @@ public class JsonMarshaller {
private ItemHint toItemHint(JSONObject object) throws Exception {
String name = object.getString("name");
List<ItemHint.ValueHint> values = new ArrayList<ItemHint.ValueHint>();
List<ItemHint.ValueHint> values = new ArrayList<>();
if (object.has("values")) {
JSONArray valuesArray = object.getJSONArray("values");
for (int i = 0; i < valuesArray.length(); i++) {
values.add(toValueHint((JSONObject) valuesArray.get(i)));
}
}
List<ItemHint.ValueProvider> providers = new ArrayList<ItemHint.ValueProvider>();
List<ItemHint.ValueProvider> providers = new ArrayList<>();
if (object.has("providers")) {
JSONArray providersObject = object.getJSONArray("providers");
for (int i = 0; i < providersObject.length(); i++) {
@@ -143,7 +143,7 @@ public class JsonMarshaller {
private ItemHint.ValueProvider toValueProvider(JSONObject object) throws Exception {
String name = object.getString("name");
Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
if (object.has("parameters")) {
JSONObject parametersObject = object.getJSONObject("parameters");
for (Iterator<?> iterator = parametersObject.keys(); iterator.hasNext();) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -296,7 +296,7 @@ public final class Metadata {
}
private <T> List<T> add(List<T> items, T item) {
List<T> result = new ArrayList<T>(items);
List<T> result = new ArrayList<>(items);
result.add(item);
return result;
}

View File

@@ -63,7 +63,7 @@ public class TestProject {
private TestCompiler compiler;
private Set<File> sourceFiles = new LinkedHashSet<File>();
private Set<File> sourceFiles = new LinkedHashSet<>();
public TestProject(TemporaryFolder tempFolder, Class<?>... classes)
throws IOException {
@@ -74,7 +74,7 @@ public class TestProject {
return TestProject.this.sourceFolder;
}
};
Set<Class<?>> contents = new HashSet<Class<?>>(Arrays.asList(classes));
Set<Class<?>> contents = new HashSet<>(Arrays.asList(classes));
contents.addAll(Arrays.asList(ALWAYS_INCLUDE));
copySources(contents);
}

View File

@@ -97,7 +97,7 @@ public abstract class AbstractFieldValuesProcessorTests {
private FieldValuesParser processor;
private Map<String, Object> values = new HashMap<String, Object>();
private Map<String, Object> values = new HashMap<>();
@Override
public synchronized void init(ProcessingEnvironment env) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class LombokExplicitProperties {
private Integer number = 0;
@Getter
private final List<String> items = new ArrayList<String>();
private final List<String> items = new ArrayList<>();
// Should be ignored if no annotation is set
@SuppressWarnings("unused")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public class LombokSimpleDataProperties {
@Deprecated
private Integer number = 0;
private final List<String> items = new ArrayList<String>();
private final List<String> items = new ArrayList<>();
private final String ignored = "foo";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class LombokSimpleProperties {
@Deprecated
private Integer number = 0;
private final List<String> items = new ArrayList<String>();
private final List<String> items = new ArrayList<>();
private final String ignored = "foo";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,11 +39,11 @@ public class SimpleCollectionProperties {
private List<Float> floats;
private final Map<String, Integer> namesToIntegers = new HashMap<String, Integer>();
private final Map<String, Integer> namesToIntegers = new HashMap<>();
private final Collection<Byte> bytes = new LinkedHashSet<Byte>();
private final Collection<Byte> bytes = new LinkedHashSet<>();
private final List<Double> doubles = new ArrayList<Double>();
private final List<Double> doubles = new ArrayList<>();
public Map<Integer, String> getIntegersToNames() {
return this.integersToNames;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,11 +42,11 @@ public class GenericConfig<T> {
private String name;
@NestedConfigurationProperty
private final Bar<String> bar = new Bar<String>();
private final Bar<String> bar = new Bar<>();
private final Map<String, Bar<Integer>> stringToBar = new HashMap<String, Bar<Integer>>();
private final Map<String, Bar<Integer>> stringToBar = new HashMap<>();
private final Map<String, Integer> stringToInteger = new HashMap<String, Integer>();
private final Map<String, Integer> stringToInteger = new HashMap<>();
public String getName() {
return this.name;
@@ -75,7 +75,7 @@ public class GenericConfig<T> {
private String name;
@NestedConfigurationProperty
private final Biz<String> biz = new Biz<String>();
private final Biz<String> biz = new Biz<>();
public String getName() {
return this.name;