This commit is contained in:
Phillip Webb
2017-05-15 17:16:03 -07:00
parent 226db4697f
commit 302f038e84
27 changed files with 91 additions and 80 deletions

View File

@@ -349,8 +349,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
}
private Element getTopLevelType(Element element) {
if ((element.getEnclosingElement() == null) ||
!(element.getEnclosingElement() instanceof TypeElement)) {
if ((element.getEnclosingElement() == null)
|| !(element.getEnclosingElement() instanceof TypeElement)) {
return element;
}
return getTopLevelType(element.getEnclosingElement());

View File

@@ -179,8 +179,8 @@ class TypeElementMembers {
return candidate;
}
TypeMirror alternative = this.typeUtils.getWrapperOrPrimitiveFor(type);
if (alternative != null &&
this.env.getTypeUtils().isSameType(returnType, alternative)) {
if (alternative != null
&& this.env.getTypeUtils().isSameType(returnType, alternative)) {
return candidate;
}
}

View File

@@ -159,14 +159,16 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
return false;
}
ItemMetadata other = (ItemMetadata) o;
return nullSafeEquals(this.itemType, other.itemType)
&& nullSafeEquals(this.name, other.name)
&& nullSafeEquals(this.type, other.type)
&& nullSafeEquals(this.description, other.description)
&& nullSafeEquals(this.sourceType, other.sourceType)
&& nullSafeEquals(this.sourceMethod, other.sourceMethod)
&& nullSafeEquals(this.defaultValue, other.defaultValue)
&& nullSafeEquals(this.deprecation, other.deprecation);
boolean result = true;
result = result && nullSafeEquals(this.itemType, other.itemType);
result = result && nullSafeEquals(this.name, other.name);
result = result && nullSafeEquals(this.type, other.type);
result = result && nullSafeEquals(this.description, other.description);
result = result && nullSafeEquals(this.sourceType, other.sourceType);
result = result && nullSafeEquals(this.sourceMethod, other.sourceMethod);
result = result && nullSafeEquals(this.defaultValue, other.defaultValue);
result = result && nullSafeEquals(this.deprecation, other.deprecation);
return result;
}
@Override

View File

@@ -352,12 +352,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void innerClassPropertiesHierachical() throws Exception {
ConfigurationMetadata metadata = compile(InnerClassHierachicalProperties.class);
assertThat(metadata)
.has(Metadata.withGroup("config.foo").ofType(InnerClassHierachicalProperties.Foo.class));
assertThat(metadata).has(
Metadata.withGroup("config.foo.bar").ofType(InnerClassHierachicalProperties.Bar.class));
assertThat(metadata).has(
Metadata.withGroup("config.foo.bar.baz").ofType(InnerClassHierachicalProperties.Foo.Baz.class));
assertThat(metadata).has(Metadata.withGroup("config.foo")
.ofType(InnerClassHierachicalProperties.Foo.class));
assertThat(metadata).has(Metadata.withGroup("config.foo.bar")
.ofType(InnerClassHierachicalProperties.Bar.class));
assertThat(metadata).has(Metadata.withGroup("config.foo.bar.baz")
.ofType(InnerClassHierachicalProperties.Foo.Baz.class));
assertThat(metadata).has(Metadata.withProperty("config.foo.bar.baz.blah"));
assertThat(metadata).has(Metadata.withProperty("config.foo.bar.bling"));
}
@@ -505,8 +505,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void lombokInnerClassWithGetterProperties() throws IOException {
ConfigurationMetadata metadata =
compile(LombokInnerClassWithGetterProperties.class);
ConfigurationMetadata metadata = compile(
LombokInnerClassWithGetterProperties.class);
assertThat(metadata).has(Metadata.withGroup("config")
.fromSource(LombokInnerClassWithGetterProperties.class));
assertThat(metadata).has(Metadata.withGroup("config.first")

View File

@@ -19,8 +19,8 @@ package org.springframework.boot.configurationsample.specific;
import org.springframework.boot.configurationsample.ConfigurationProperties;
/**
* Demonstrate inner classes end up in metadata regardless of
* position in hierarchy and without the use of
* Demonstrate inner classes end up in metadata regardless of position in hierarchy and
* without the use of
* {@link org.springframework.boot.configurationsample.NestedConfigurationProperty}.
*
* @author Madhura Bhave
@@ -61,7 +61,9 @@ public class InnerClassHierachicalProperties {
public void setBlah(String blah) {
this.blah = blah;
}
}
}
public static class Bar {
@@ -85,6 +87,7 @@ public class InnerClassHierachicalProperties {
public void setBaz(Foo.Baz baz) {
this.baz = baz;
}
}
}