Polish
This commit is contained in:
@@ -51,8 +51,7 @@ class TypeElementMembers {
|
||||
|
||||
private final Map<String, ExecutableElement> publicGetters = new LinkedHashMap<String, ExecutableElement>();
|
||||
|
||||
private final Map<String, List<ExecutableElement>> publicSetters =
|
||||
new LinkedHashMap<String, List<ExecutableElement>>();
|
||||
private final Map<String, List<ExecutableElement>> publicSetters = new LinkedHashMap<String, List<ExecutableElement>>();
|
||||
|
||||
TypeElementMembers(ProcessingEnvironment env, TypeElement element) {
|
||||
this.env = env;
|
||||
@@ -84,7 +83,8 @@ class TypeElementMembers {
|
||||
}
|
||||
else if (isSetter(method)) {
|
||||
String propertyName = getAccessorName(name);
|
||||
List<ExecutableElement> matchingSetters = this.publicSetters.get(propertyName);
|
||||
List<ExecutableElement> matchingSetters = this.publicSetters
|
||||
.get(propertyName);
|
||||
if (matchingSetters == null) {
|
||||
matchingSetters = new ArrayList<ExecutableElement>();
|
||||
this.publicSetters.put(propertyName, matchingSetters);
|
||||
@@ -97,7 +97,8 @@ class TypeElementMembers {
|
||||
}
|
||||
}
|
||||
|
||||
private ExecutableElement getMatchingSetter(List<ExecutableElement> candidates, TypeMirror type) {
|
||||
private ExecutableElement getMatchingSetter(List<ExecutableElement> candidates,
|
||||
TypeMirror type) {
|
||||
for (ExecutableElement candidate : candidates) {
|
||||
TypeMirror paramType = candidate.getParameters().get(0).asType();
|
||||
if (this.env.getTypeUtils().isSameType(paramType, type)) {
|
||||
|
||||
@@ -40,7 +40,6 @@ import javax.lang.model.util.Types;
|
||||
class TypeUtils {
|
||||
|
||||
private static final Map<TypeKind, Class<?>> PRIMITIVE_WRAPPERS;
|
||||
private static final Map<String, TypeKind> WRAPPER_TO_PRIMITIVE;
|
||||
|
||||
static {
|
||||
Map<TypeKind, Class<?>> wrappers = new HashMap<TypeKind, Class<?>>();
|
||||
@@ -53,16 +52,15 @@ class TypeUtils {
|
||||
wrappers.put(TypeKind.LONG, Long.class);
|
||||
wrappers.put(TypeKind.SHORT, Short.class);
|
||||
PRIMITIVE_WRAPPERS = Collections.unmodifiableMap(wrappers);
|
||||
}
|
||||
|
||||
private static final Map<String, TypeKind> WRAPPER_TO_PRIMITIVE;
|
||||
|
||||
static {
|
||||
Map<String, TypeKind> primitives = new HashMap<String, TypeKind>();
|
||||
primitives.put(Boolean.class.getName(), TypeKind.BOOLEAN);
|
||||
primitives.put(Byte.class.getName(), TypeKind.BYTE);
|
||||
primitives.put(Character.class.getName(), TypeKind.CHAR);
|
||||
primitives.put(Double.class.getName(), TypeKind.DOUBLE);
|
||||
primitives.put(Float.class.getName(), TypeKind.FLOAT);
|
||||
primitives.put(Integer.class.getName(), TypeKind.INT);
|
||||
primitives.put(Long.class.getName(), TypeKind.LONG);
|
||||
primitives.put(Short.class.getName(), TypeKind.SHORT);
|
||||
for (Map.Entry<TypeKind, Class<?>> entry : PRIMITIVE_WRAPPERS.entrySet()) {
|
||||
primitives.put(entry.getValue().getName(), entry.getKey());
|
||||
}
|
||||
WRAPPER_TO_PRIMITIVE = primitives;
|
||||
}
|
||||
|
||||
@@ -111,7 +109,6 @@ class TypeUtils {
|
||||
|| this.env.getTypeUtils().isAssignable(type, this.mapType);
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnclosedIn(Element candidate, TypeElement element) {
|
||||
if (candidate == null || element == null) {
|
||||
return false;
|
||||
@@ -134,7 +131,8 @@ class TypeUtils {
|
||||
public TypeMirror getWrapperOrPrimitiveFor(TypeMirror typeMirror) {
|
||||
Class<?> candidate = getWrapperFor(typeMirror);
|
||||
if (candidate != null) {
|
||||
return this.env.getElementUtils().getTypeElement(candidate.getName()).asType();
|
||||
return this.env.getElementUtils().getTypeElement(candidate.getName())
|
||||
.asType();
|
||||
}
|
||||
TypeKind primitiveKind = getPrimitiveFor(typeMirror);
|
||||
if (primitiveKind != null) {
|
||||
|
||||
@@ -205,11 +205,9 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
ConfigurationMetadata metadata = compile(type);
|
||||
assertThat(metadata, containsGroup("not.deprecated").fromSource(type));
|
||||
assertThat(metadata, containsProperty("not.deprecated.counter", Integer.class)
|
||||
.withNoDeprecation()
|
||||
.fromSource(type));
|
||||
.withNoDeprecation().fromSource(type));
|
||||
assertThat(metadata, containsProperty("not.deprecated.flag", Boolean.class)
|
||||
.withNoDeprecation()
|
||||
.fromSource(type));
|
||||
.withNoDeprecation().fromSource(type));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,10 +215,10 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
Class<?> type = BoxingPojo.class;
|
||||
ConfigurationMetadata metadata = compile(type);
|
||||
assertThat(metadata, containsGroup("boxing").fromSource(type));
|
||||
assertThat(metadata, containsProperty("boxing.flag", Boolean.class)
|
||||
.fromSource(type));
|
||||
assertThat(metadata, containsProperty("boxing.counter", Integer.class)
|
||||
.fromSource(type));
|
||||
assertThat(metadata,
|
||||
containsProperty("boxing.flag", Boolean.class).fromSource(type));
|
||||
assertThat(metadata,
|
||||
containsProperty("boxing.counter", Integer.class).fromSource(type));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -366,12 +364,9 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
null, null, true, null);
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.flag", Boolean.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("A simple flag.")
|
||||
.withDeprecation(null, null)
|
||||
.withDefaultValue(is(true)));
|
||||
assertThat(metadata, containsProperty("simple.flag", Boolean.class)
|
||||
.fromSource(SimpleProperties.class).withDescription("A simple flag.")
|
||||
.withDeprecation(null, null).withDefaultValue(is(true)));
|
||||
assertThat(metadata.getItems().size(), is(4));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.boot.configurationsample.specific;
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate the use of boxing/unboxing. Even if the type does not
|
||||
* strictly match, it should still be detected.
|
||||
* Demonstrate the use of boxing/unboxing. Even if the type does not strictly match, it
|
||||
* should still be detected.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.boot.configurationsample.specific;
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate that an unrelated setter is not taken into account
|
||||
* to detect the deprecated flag.
|
||||
* Demonstrate that an unrelated setter is not taken into account to detect the deprecated
|
||||
* flag.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user