Merge branch '1.5.x'
This commit is contained in:
commit
ba6be4f22f
|
@ -26,6 +26,7 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.ArrayType;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.PrimitiveType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
@ -197,6 +198,11 @@ class TypeUtils {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitArray(ArrayType t, Void none) {
|
||||
return t.getComponentType().accept(this, none) + "[]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitPrimitive(PrimitiveType t, Void none) {
|
||||
return this.types.boxedClass(t).getQualifiedName().toString();
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.springframework.boot.configurationsample.simple.ClassWithNestedProper
|
|||
import org.springframework.boot.configurationsample.simple.DeprecatedSingleProperty;
|
||||
import org.springframework.boot.configurationsample.simple.HierarchicalProperties;
|
||||
import org.springframework.boot.configurationsample.simple.NotAnnotated;
|
||||
import org.springframework.boot.configurationsample.simple.SimpleArrayProperties;
|
||||
import org.springframework.boot.configurationsample.simple.SimpleCollectionProperties;
|
||||
import org.springframework.boot.configurationsample.simple.SimplePrefixValueProperties;
|
||||
import org.springframework.boot.configurationsample.simple.SimpleProperties;
|
||||
|
@ -80,6 +81,7 @@ import org.springframework.boot.configurationsample.specific.InnerClassRootConfi
|
|||
import org.springframework.boot.configurationsample.specific.InvalidAccessorProperties;
|
||||
import org.springframework.boot.configurationsample.specific.InvalidDoubleRegistrationProperties;
|
||||
import org.springframework.boot.configurationsample.specific.SimplePojo;
|
||||
import org.springframework.boot.configurationsample.specific.WildcardConfig;
|
||||
import org.springframework.boot.testsupport.compiler.TestCompiler;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
|
@ -272,6 +274,22 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
|||
"java.util.Map<java.lang.String,org.springframework.boot.configurationsample.simple.SimpleCollectionProperties.Holder<java.lang.String>>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseArrayConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleArrayProperties.class);
|
||||
assertThat(metadata).has(Metadata.withGroup("array")
|
||||
.ofType(SimpleArrayProperties.class));
|
||||
assertThat(metadata).has(Metadata.withProperty("array.primitive",
|
||||
"java.lang.Integer[]"));
|
||||
assertThat(metadata).has(Metadata.withProperty("array.simple",
|
||||
"java.lang.String[]"));
|
||||
assertThat(metadata).has(Metadata.withProperty("array.inner",
|
||||
"org.springframework.boot.configurationsample.simple.SimpleArrayProperties$Holder[]"));
|
||||
assertThat(metadata).has(Metadata.withProperty("array.name-to-integer",
|
||||
"java.util.Map<java.lang.String,java.lang.Integer>[]"));
|
||||
assertThat(metadata.getItems()).hasSize(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleMethodConfig() {
|
||||
ConfigurationMetadata metadata = compile(SimpleMethodConfig.class);
|
||||
|
@ -482,6 +500,20 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
|||
assertThat(metadata.getItems()).hasSize(9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wildcardTypes() throws IOException {
|
||||
ConfigurationMetadata metadata = compile(WildcardConfig.class);
|
||||
assertThat(metadata).has(Metadata.withGroup("wildcard")
|
||||
.ofType(WildcardConfig.class));
|
||||
assertThat(metadata).has(Metadata.withProperty("wildcard.string-to-number")
|
||||
.ofType("java.util.Map<java.lang.String,? extends java.lang.Number>")
|
||||
.fromSource(WildcardConfig.class));
|
||||
assertThat(metadata).has(Metadata.withProperty("wildcard.integers")
|
||||
.ofType("java.util.List<? super java.lang.Integer>")
|
||||
.fromSource(WildcardConfig.class));
|
||||
assertThat(metadata.getItems()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lombokDataProperties() {
|
||||
ConfigurationMetadata metadata = compile(LombokSimpleDataProperties.class);
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2012-2018 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.configurationsample.simple;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties with array.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("array")
|
||||
public class SimpleArrayProperties {
|
||||
|
||||
private int[] primitive;
|
||||
|
||||
private String[] simple;
|
||||
|
||||
private Holder[] inner;
|
||||
|
||||
private Map<String, Integer>[] nameToInteger;
|
||||
|
||||
public int[] getPrimitive() {
|
||||
return this.primitive;
|
||||
}
|
||||
|
||||
public void setPrimitive(int[] primitive) {
|
||||
this.primitive = primitive;
|
||||
}
|
||||
|
||||
public String[] getSimple() {
|
||||
return this.simple;
|
||||
}
|
||||
|
||||
public void setSimple(String[] simple) {
|
||||
this.simple = simple;
|
||||
}
|
||||
|
||||
public Holder[] getInner() {
|
||||
return this.inner;
|
||||
}
|
||||
|
||||
public void setInner(Holder[] inner) {
|
||||
this.inner = inner;
|
||||
}
|
||||
|
||||
public Map<String, Integer>[] getNameToInteger() {
|
||||
return this.nameToInteger;
|
||||
}
|
||||
|
||||
public void setNameToInteger(Map<String, Integer>[] nameToInteger) {
|
||||
this.nameToInteger = nameToInteger;
|
||||
}
|
||||
|
||||
public static class Holder {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2012-2018 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.configurationsample.specific;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate properties with a wildcard type.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("wildcard")
|
||||
public class WildcardConfig {
|
||||
|
||||
private Map<String, ? extends Number> stringToNumber;
|
||||
|
||||
private List<? super Integer> integers;
|
||||
|
||||
public Map<String, ? extends Number> getStringToNumber() {
|
||||
return this.stringToNumber;
|
||||
}
|
||||
|
||||
public void setStringToNumber(Map<String, ? extends Number> stringToNumber) {
|
||||
this.stringToNumber = stringToNumber;
|
||||
}
|
||||
|
||||
public List<? super Integer> getIntegers() {
|
||||
return this.integers;
|
||||
}
|
||||
|
||||
public void setIntegers(List<? super Integer> integers) {
|
||||
this.integers = integers;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue