Reformat code use Eclipse Mars
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -92,14 +92,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
public void simpleProperties() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata, containsGroup("simple").fromSource(SimpleProperties.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.the-name", String.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("The name of this simple properties.")
|
||||
.withDefaultValue(is("boot")).withDeprecated());
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.flag", Boolean.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("A simple flag.").withDeprecated());
|
||||
@@ -113,10 +111,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
ConfigurationMetadata metadata = compile(SimplePrefixValueProperties.class);
|
||||
assertThat(metadata,
|
||||
containsGroup("simple").fromSource(SimplePrefixValueProperties.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("simple.name", String.class).fromSource(
|
||||
SimplePrefixValueProperties.class));
|
||||
assertThat(metadata, containsProperty("simple.name", String.class)
|
||||
.fromSource(SimplePrefixValueProperties.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,69 +177,48 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
public void parseCollectionConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleCollectionProperties.class);
|
||||
// getter and setter
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.integers-to-names",
|
||||
"java.util.Map<java.lang.Integer,java.lang.String>"));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.longs",
|
||||
"java.util.Collection<java.lang.Long>"));
|
||||
assertThat(metadata, containsProperty("collection.integers-to-names",
|
||||
"java.util.Map<java.lang.Integer,java.lang.String>"));
|
||||
assertThat(metadata, containsProperty("collection.longs",
|
||||
"java.util.Collection<java.lang.Long>"));
|
||||
assertThat(metadata,
|
||||
containsProperty("collection.floats", "java.util.List<java.lang.Float>"));
|
||||
// getter only
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.names-to-integers",
|
||||
"java.util.Map<java.lang.String,java.lang.Integer>"));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.bytes",
|
||||
"java.util.Collection<java.lang.Byte>"));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.doubles", "java.util.List<java.lang.Double>"));
|
||||
assertThat(metadata, containsProperty("collection.names-to-integers",
|
||||
"java.util.Map<java.lang.String,java.lang.Integer>"));
|
||||
assertThat(metadata, containsProperty("collection.bytes",
|
||||
"java.util.Collection<java.lang.Byte>"));
|
||||
assertThat(metadata, containsProperty("collection.doubles",
|
||||
"java.util.List<java.lang.Double>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleMethodConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleMethodConfig.class);
|
||||
assertThat(metadata, containsGroup("foo").fromSource(SimpleMethodConfig.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("foo.name", String.class).fromSource(
|
||||
SimpleMethodConfig.Foo.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("foo.flag", Boolean.class).fromSource(
|
||||
SimpleMethodConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("foo.name", String.class)
|
||||
.fromSource(SimpleMethodConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("foo.flag", Boolean.class)
|
||||
.fromSource(SimpleMethodConfig.Foo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidMethodConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(InvalidMethodConfig.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("something.name", String.class).fromSource(
|
||||
InvalidMethodConfig.class));
|
||||
assertThat(metadata, containsProperty("something.name", String.class)
|
||||
.fromSource(InvalidMethodConfig.class));
|
||||
assertThat(metadata, not(containsProperty("invalid.name")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodAndClassConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(MethodAndClassConfig.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("conflict.name", String.class).fromSource(
|
||||
MethodAndClassConfig.Foo.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("conflict.flag", Boolean.class).fromSource(
|
||||
MethodAndClassConfig.Foo.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("conflict.value", String.class).fromSource(
|
||||
MethodAndClassConfig.class));
|
||||
assertThat(metadata, containsProperty("conflict.name", String.class)
|
||||
.fromSource(MethodAndClassConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("conflict.flag", Boolean.class)
|
||||
.fromSource(MethodAndClassConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("conflict.value", String.class)
|
||||
.fromSource(MethodAndClassConfig.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -320,7 +295,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Test
|
||||
public void lombokExplicitProperties() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(LombokExplicitProperties.class);
|
||||
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class, "explicit");
|
||||
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class,
|
||||
"explicit");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -347,9 +323,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
|
||||
assertThat(metadata, containsProperty("simple.comparator"));
|
||||
|
||||
assertThat(metadata,
|
||||
containsProperty("foo", String.class)
|
||||
.fromSource(AdditionalMetadata.class));
|
||||
assertThat(metadata, containsProperty("foo", String.class)
|
||||
.fromSource(AdditionalMetadata.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -411,9 +386,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
containsProperty("foo.counter").fromSource(FooProperties.class));
|
||||
assertThat(metadata,
|
||||
containsProperty("bar.counter").fromSource(BarProperties.class));
|
||||
assertThat(metadata,
|
||||
not(containsProperty("bar.counter")
|
||||
.fromSource(RenamedBarProperties.class)));
|
||||
assertThat(metadata, not(
|
||||
containsProperty("bar.counter").fromSource(RenamedBarProperties.class)));
|
||||
|
||||
project.delete(BarProperties.class);
|
||||
project.add(RenamedBarProperties.class);
|
||||
@@ -430,9 +404,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
Class<?> source, String prefix) {
|
||||
assertThat(metadata, containsGroup(prefix).fromSource(source));
|
||||
assertThat(metadata, not(containsProperty(prefix + ".id")));
|
||||
assertThat(metadata,
|
||||
containsProperty(prefix + ".name", String.class).fromSource(source)
|
||||
.withDescription("Name description."));
|
||||
assertThat(metadata, containsProperty(prefix + ".name", String.class)
|
||||
.fromSource(source).withDescription("Name description."));
|
||||
assertThat(metadata, containsProperty(prefix + ".description"));
|
||||
assertThat(metadata, containsProperty(prefix + ".counter"));
|
||||
assertThat(metadata, containsProperty(prefix + ".number").fromSource(source)
|
||||
|
||||
@@ -119,12 +119,12 @@ public class ConfigurationMetadataMatchers {
|
||||
ConfigurationMetadata metadata = (ConfigurationMetadata) item;
|
||||
ItemMetadata property = getFirstPropertyWithName(metadata, this.name);
|
||||
if (property == null) {
|
||||
description.appendText("missing "
|
||||
+ this.itemType.toString().toLowerCase() + " " + this.name);
|
||||
description.appendText("missing " + this.itemType.toString().toLowerCase()
|
||||
+ " " + this.name);
|
||||
}
|
||||
else {
|
||||
description.appendText(
|
||||
"was " + this.itemType.toString().toLowerCase() + " ")
|
||||
description
|
||||
.appendText("was " + this.itemType.toString().toLowerCase() + " ")
|
||||
.appendValue(property);
|
||||
}
|
||||
}
|
||||
@@ -151,12 +151,14 @@ public class ConfigurationMetadataMatchers {
|
||||
|
||||
public ContainsItemMatcher ofType(Class<?> dataType) {
|
||||
return new ContainsItemMatcher(this.itemType, this.name, dataType.getName(),
|
||||
this.sourceType, this.description, this.defaultValue, this.deprecated);
|
||||
this.sourceType, this.description, this.defaultValue,
|
||||
this.deprecated);
|
||||
}
|
||||
|
||||
public ContainsItemMatcher ofType(String dataType) {
|
||||
return new ContainsItemMatcher(this.itemType, this.name, dataType,
|
||||
this.sourceType, this.description, this.defaultValue, this.deprecated);
|
||||
this.sourceType, this.description, this.defaultValue,
|
||||
this.deprecated);
|
||||
}
|
||||
|
||||
public ContainsItemMatcher fromSource(Class<?> sourceType) {
|
||||
|
||||
@@ -73,9 +73,10 @@ public class TestCompiler {
|
||||
return getTask(javaFileObjects);
|
||||
}
|
||||
|
||||
private TestCompilationTask getTask(Iterable<? extends JavaFileObject> javaFileObjects) {
|
||||
return new TestCompilationTask(this.compiler.getTask(null, this.fileManager,
|
||||
null, null, null, javaFileObjects));
|
||||
private TestCompilationTask getTask(
|
||||
Iterable<? extends JavaFileObject> javaFileObjects) {
|
||||
return new TestCompilationTask(this.compiler.getTask(null, this.fileManager, null,
|
||||
null, null, javaFileObjects));
|
||||
}
|
||||
|
||||
public File getOutputLocation() {
|
||||
|
||||
@@ -34,8 +34,8 @@ import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller;
|
||||
*/
|
||||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_6)
|
||||
public class TestConfigurationMetadataAnnotationProcessor extends
|
||||
ConfigurationMetadataAnnotationProcessor {
|
||||
public class TestConfigurationMetadataAnnotationProcessor
|
||||
extends ConfigurationMetadataAnnotationProcessor {
|
||||
|
||||
static final String CONFIGURATION_PROPERTIES_ANNOTATION = "org.springframework.boot.configurationsample.ConfigurationProperties";
|
||||
|
||||
@@ -66,8 +66,8 @@ public class TestConfigurationMetadataAnnotationProcessor extends
|
||||
File metadataFile = new File(this.outputLocation,
|
||||
"META-INF/spring-configuration-metadata.json");
|
||||
if (metadataFile.isFile()) {
|
||||
this.metadata = new JsonMarshaller().read(new FileInputStream(
|
||||
metadataFile));
|
||||
this.metadata = new JsonMarshaller()
|
||||
.read(new FileInputStream(metadataFile));
|
||||
}
|
||||
else {
|
||||
this.metadata = new ConfigurationMetadata();
|
||||
|
||||
@@ -140,8 +140,8 @@ public class TestProject {
|
||||
File targetFile = getSourceFile(target);
|
||||
String contents = getContents(targetFile);
|
||||
int insertAt = contents.lastIndexOf('}');
|
||||
String additionalSource = FileCopyUtils.copyToString(new InputStreamReader(
|
||||
snippetStream));
|
||||
String additionalSource = FileCopyUtils
|
||||
.copyToString(new InputStreamReader(snippetStream));
|
||||
contents = contents.substring(0, insertAt) + additionalSource
|
||||
+ contents.substring(insertAt);
|
||||
putContents(targetFile, contents);
|
||||
|
||||
@@ -82,8 +82,8 @@ public abstract class AbstractFieldValuesProcessorTests {
|
||||
equalToObject(new Object[] { "FOO", "BAR" }));
|
||||
assertThat(values.get("stringArrayNone"), nullValue());
|
||||
assertThat(values.get("stringEmptyArray"), equalToObject(new Object[0]));
|
||||
assertThat(values.get("stringArrayConst"), equalToObject(new Object[] { "OK",
|
||||
"KO" }));
|
||||
assertThat(values.get("stringArrayConst"),
|
||||
equalToObject(new Object[] { "OK", "KO" }));
|
||||
assertThat(values.get("stringArrayConstElements"),
|
||||
equalToObject(new Object[] { "c" }));
|
||||
assertThat(values.get("integerArray"), equalToObject(new Object[] { 42, 24 }));
|
||||
@@ -94,7 +94,8 @@ public abstract class AbstractFieldValuesProcessorTests {
|
||||
return equalTo(object);
|
||||
}
|
||||
|
||||
@SupportedAnnotationTypes({ "org.springframework.boot.configurationsample.ConfigurationProperties" })
|
||||
@SupportedAnnotationTypes({
|
||||
"org.springframework.boot.configurationsample.ConfigurationProperties" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_6)
|
||||
private class TestProcessor extends AbstractProcessor {
|
||||
|
||||
@@ -114,8 +115,8 @@ public abstract class AbstractFieldValuesProcessorTests {
|
||||
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
|
||||
if (element instanceof TypeElement) {
|
||||
try {
|
||||
this.values.putAll(this.processor
|
||||
.getFieldValues((TypeElement) element));
|
||||
this.values.putAll(
|
||||
this.processor.getFieldValues((TypeElement) element));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
|
||||
@@ -28,8 +28,8 @@ import static org.junit.Assume.assumeNoException;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class JavaCompilerFieldValuesProcessorTests extends
|
||||
AbstractFieldValuesProcessorTests {
|
||||
public class JavaCompilerFieldValuesProcessorTests
|
||||
extends AbstractFieldValuesProcessorTests {
|
||||
|
||||
@Override
|
||||
protected FieldValuesParser createProcessor(ProcessingEnvironment env) {
|
||||
|
||||
@@ -40,7 +40,8 @@ public class ConfigurationMetadataTests {
|
||||
|
||||
@Test
|
||||
public void toDashedCaseWordsSeveralUnderScores() {
|
||||
assertThat(toDashedCase("Word___With__underscore"), is("word___with__underscore"));
|
||||
assertThat(toDashedCase("Word___With__underscore"),
|
||||
is("word___with__underscore"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,12 +41,12 @@ public class JsonMarshallerTests {
|
||||
ConfigurationMetadata metadata = new ConfigurationMetadata();
|
||||
metadata.add(ItemMetadata.newProperty("a", "b", StringBuffer.class.getName(),
|
||||
InputStream.class.getName(), "sourceMethod", "desc", "x", true));
|
||||
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null,
|
||||
null, false));
|
||||
metadata.add(ItemMetadata.newProperty("c", null, null, null, null, null, 123,
|
||||
false));
|
||||
metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true,
|
||||
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null, null,
|
||||
false));
|
||||
metadata.add(
|
||||
ItemMetadata.newProperty("c", null, null, null, null, null, 123, false));
|
||||
metadata.add(
|
||||
ItemMetadata.newProperty("d", null, null, null, null, null, true, false));
|
||||
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
|
||||
new String[] { "y", "n" }, false));
|
||||
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
|
||||
@@ -55,8 +55,8 @@ public class JsonMarshallerTests {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
JsonMarshaller marshaller = new JsonMarshaller();
|
||||
marshaller.write(metadata, outputStream);
|
||||
ConfigurationMetadata read = marshaller.read(new ByteArrayInputStream(
|
||||
outputStream.toByteArray()));
|
||||
ConfigurationMetadata read = marshaller
|
||||
.read(new ByteArrayInputStream(outputStream.toByteArray()));
|
||||
assertThat(read,
|
||||
containsProperty("a.b", StringBuffer.class).fromSource(InputStream.class)
|
||||
.withDescription("desc").withDefaultValue(is("x"))
|
||||
@@ -66,8 +66,8 @@ public class JsonMarshallerTests {
|
||||
assertThat(read, containsProperty("d").withDefaultValue(is(true)));
|
||||
assertThat(read,
|
||||
containsProperty("e").withDefaultValue(is(new String[] { "y", "n" })));
|
||||
assertThat(read,
|
||||
containsProperty("f").withDefaultValue(is(new boolean[] { true, false })));
|
||||
assertThat(read, containsProperty("f")
|
||||
.withDefaultValue(is(new boolean[] { true, false })));
|
||||
assertThat(read, containsGroup("d"));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ package org.springframework.boot.configurationsample.simple;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public abstract class HierarchicalPropertiesParent extends
|
||||
HierarchicalPropertiesGrandparent {
|
||||
public abstract class HierarchicalPropertiesParent
|
||||
extends HierarchicalPropertiesGrandparent {
|
||||
|
||||
private String second;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user