Reformat code use Eclipse Mars

This commit is contained in:
Phillip Webb
2015-10-07 23:32:31 -07:00
parent ba7c1fda72
commit 6ab376e2e8
652 changed files with 4151 additions and 3919 deletions

View File

@@ -160,13 +160,13 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private void processExecutableElement(String prefix, ExecutableElement element) {
if (element.getModifiers().contains(Modifier.PUBLIC)
&& (TypeKind.VOID != element.getReturnType().getKind())) {
Element returns = this.processingEnv.getTypeUtils().asElement(
element.getReturnType());
Element returns = this.processingEnv.getTypeUtils()
.asElement(element.getReturnType());
if (returns instanceof TypeElement) {
this.metadataCollector.add(ItemMetadata.newGroup(prefix,
this.typeUtils.getType(returns),
this.typeUtils.getType(element.getEnclosingElement()),
element.toString()));
this.metadataCollector.add(
ItemMetadata.newGroup(prefix, this.typeUtils.getType(returns),
this.typeUtils.getType(element.getEnclosingElement()),
element.toString()));
processTypeElement(prefix, (TypeElement) returns);
}
}
@@ -198,8 +198,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
ExecutableElement setter = members.getPublicSetters().get(name);
VariableElement field = members.getFields().get(name);
TypeMirror returnType = getter.getReturnType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(
returnType);
Element returnTypeElement = this.processingEnv.getTypeUtils()
.asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
@@ -211,9 +211,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean deprecated = hasDeprecateAnnotation(getter)
|| hasDeprecateAnnotation(setter)
|| hasDeprecateAnnotation(element);
this.metadataCollector.add(ItemMetadata
.newProperty(prefix, name, dataType, sourceType, null,
description, defaultValue, deprecated));
this.metadataCollector
.add(ItemMetadata.newProperty(prefix, name, dataType, sourceType,
null, description, defaultValue, deprecated));
}
}
}
@@ -227,8 +227,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
continue;
}
TypeMirror returnType = field.asType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(
returnType);
Element returnTypeElement = this.processingEnv.getTypeUtils()
.asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
@@ -240,9 +240,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
Object defaultValue = fieldValues.get(name);
boolean deprecated = hasDeprecateAnnotation(field)
|| hasDeprecateAnnotation(element);
this.metadataCollector.add(ItemMetadata
.newProperty(prefix, name, dataType, sourceType, null,
description, defaultValue, deprecated));
this.metadataCollector
.add(ItemMetadata.newProperty(prefix, name, dataType, sourceType,
null, description, defaultValue, deprecated));
}
}
}
@@ -256,8 +256,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private boolean hasLombokSetter(VariableElement field, TypeElement element) {
return !field.getModifiers().contains(Modifier.FINAL)
&& (hasAnnotation(field, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION) || hasAnnotation(
element, LOMBOK_DATA_ANNOTATION));
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_DATA_ANNOTATION));
}
private void processNestedTypes(String prefix, TypeElement element,
@@ -267,8 +267,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
String name = entry.getKey();
ExecutableElement getter = entry.getValue();
VariableElement field = members.getFields().get(name);
Element returnType = this.processingEnv.getTypeUtils().asElement(
getter.getReturnType());
Element returnType = this.processingEnv.getTypeUtils()
.asElement(getter.getReturnType());
AnnotationMirror annotation = getAnnotation(getter,
configurationPropertiesAnnotation());
boolean isNested = isNested(returnType, field, element);
@@ -328,8 +328,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
Map<String, Object> values = new LinkedHashMap<String, Object>();
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
.getElementValues().entrySet()) {
values.put(entry.getKey().getSimpleName().toString(), entry.getValue()
.getValue());
values.put(entry.getKey().getSimpleName().toString(),
entry.getValue().getValue());
}
return values;
}
@@ -349,7 +349,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
return null;
}
private ConfigurationMetadata mergeAdditionalMetadata(ConfigurationMetadata metadata) {
private ConfigurationMetadata mergeAdditionalMetadata(
ConfigurationMetadata metadata) {
try {
ConfigurationMetadata merged = new ConfigurationMetadata(metadata);
merged.addAll(this.metadataStore.readAdditionalMetadata());

View File

@@ -95,11 +95,13 @@ public class MetadataCollector {
private boolean shouldBeMerged(ItemMetadata itemMetadata) {
String sourceType = itemMetadata.getSourceType();
return (sourceType != null && !deletedInCurrentBuild(sourceType) && !processedInCurrentBuild(sourceType));
return (sourceType != null && !deletedInCurrentBuild(sourceType)
&& !processedInCurrentBuild(sourceType));
}
private boolean deletedInCurrentBuild(String sourceType) {
return this.processingEnvironment.getElementUtils().getTypeElement(sourceType) == null;
return this.processingEnvironment.getElementUtils()
.getTypeElement(sourceType) == null;
}
private boolean processedInCurrentBuild(String sourceType) {

View File

@@ -89,21 +89,21 @@ public class MetadataStore {
}
private FileObject getMetadataResource() throws IOException {
FileObject resource = this.environment.getFiler().getResource(
StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
FileObject resource = this.environment.getFiler()
.getResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
return resource;
}
private FileObject createMetadataResource() throws IOException {
FileObject resource = this.environment.getFiler().createResource(
StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
FileObject resource = this.environment.getFiler()
.createResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
return resource;
}
private InputStream getAdditionalMetadataStream() throws IOException {
// Most build systems will have copied the file to the class output location
FileObject fileObject = this.environment.getFiler().getResource(
StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
FileObject fileObject = this.environment.getFiler()
.getResource(StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
File file = new File(fileObject.toUri());
if (!file.exists()) {
// Gradle keeps things separate
@@ -115,8 +115,8 @@ public class MetadataStore {
file = new File(path);
}
}
return (file.exists() ? new FileInputStream(file) : fileObject.toUri().toURL()
.openStream());
return (file.exists() ? new FileInputStream(file)
: fileObject.toUri().toURL().openStream());
}
}

View File

@@ -54,8 +54,8 @@ class TypeElementMembers {
}
private void process(TypeElement element) {
for (ExecutableElement method : ElementFilter.methodsIn(element
.getEnclosedElements())) {
for (ExecutableElement method : ElementFilter
.methodsIn(element.getEnclosedElements())) {
processMethod(method);
}
for (VariableElement field : ElementFilter
@@ -95,14 +95,14 @@ class TypeElementMembers {
}
private boolean isSetterReturnType(ExecutableElement method) {
return (TypeKind.VOID == method.getReturnType().getKind() || this.env
.getTypeUtils().isSameType(method.getEnclosingElement().asType(),
method.getReturnType()));
return (TypeKind.VOID == method.getReturnType().getKind()
|| this.env.getTypeUtils().isSameType(
method.getEnclosingElement().asType(), method.getReturnType()));
}
private String getAccessorName(String methodName) {
String name = methodName.startsWith("is") ? methodName.substring(2) : methodName
.substring(3);
String name = methodName.startsWith("is") ? methodName.substring(2)
: methodName.substring(3);
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
return name;
}

View File

@@ -40,6 +40,7 @@ import javax.lang.model.util.Types;
class TypeUtils {
private static final Map<TypeKind, Class<?>> PRIMITIVE_WRAPPERS;
static {
Map<TypeKind, Class<?>> wrappers = new HashMap<TypeKind, Class<?>>();
wrappers.put(TypeKind.BOOLEAN, Boolean.class);
@@ -63,8 +64,9 @@ class TypeUtils {
this.env = env;
Types types = env.getTypeUtils();
WildcardType wc = types.getWildcardType(null, null);
this.collectionType = types.getDeclaredType(this.env.getElementUtils()
.getTypeElement(Collection.class.getName()), wc);
this.collectionType = types.getDeclaredType(
this.env.getElementUtils().getTypeElement(Collection.class.getName()),
wc);
this.mapType = types.getDeclaredType(
this.env.getElementUtils().getTypeElement(Map.class.getName()), wc, wc);
@@ -109,8 +111,8 @@ class TypeUtils {
}
public String getJavaDoc(Element element) {
String javadoc = (element == null ? null : this.env.getElementUtils()
.getDocComment(element));
String javadoc = (element == null ? null
: this.env.getElementUtils().getDocComment(element));
if (javadoc != null) {
javadoc = javadoc.trim();
}

View File

@@ -30,9 +30,11 @@ class ExpressionTree extends ReflectionWrapper {
private final Class<?> literalTreeType = findClass("com.sun.source.tree.LiteralTree");
private final Method literalValueMethod = findMethod(this.literalTreeType, "getValue");
private final Method literalValueMethod = findMethod(this.literalTreeType,
"getValue");
private final Class<?> newArrayTreeType = findClass("com.sun.source.tree.NewArrayTree");
private final Class<?> newArrayTreeType = findClass(
"com.sun.source.tree.NewArrayTree");
private final Method arrayValueMethod = findMethod(this.newArrayTreeType,
"getInitializers");

View File

@@ -56,6 +56,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
private static class FieldCollector implements TreeVisitor {
private static final Map<String, Class<?>> WRAPPER_TYPES;
static {
Map<String, Class<?>> types = new HashMap<String, Class<?>>();
types.put("boolean", Boolean.class);
@@ -72,6 +73,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
}
private static final Map<Class<?>, Object> DEFAULT_TYPE_VALUES;
static {
Map<Class<?>, Object> values = new HashMap<Class<?>, Object>();
values.put(Boolean.class, false);
@@ -83,6 +85,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
}
private static final Map<String, Object> WELL_KNOWN_STATIC_FINALS;
static {
Map<String, Object> values = new HashMap<String, Object>();
values.put("Boolean.TRUE", true);

View File

@@ -41,9 +41,11 @@ class Tree extends ReflectionWrapper {
}
public void accept(TreeVisitor visitor) throws Exception {
this.acceptMethod.invoke(getInstance(), Proxy.newProxyInstance(getInstance()
.getClass().getClassLoader(), new Class<?>[] { this.treeVisitorType },
new TreeVisitorInvocationHandler(visitor)), 0);
this.acceptMethod.invoke(getInstance(),
Proxy.newProxyInstance(getInstance().getClass().getClassLoader(),
new Class<?>[] { this.treeVisitorType },
new TreeVisitorInvocationHandler(visitor)),
0);
}
/**
@@ -59,7 +61,8 @@ class Tree extends ReflectionWrapper {
@Override
@SuppressWarnings("rawtypes")
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if (method.getName().equals("visitClass")) {
if ((Integer) args[1] == 0) {
Iterable members = (Iterable) Tree.this.GET_CLASS_TREE_MEMBERS