Merge branch '1.2.x'

This commit is contained in:
Phillip Webb
2015-10-07 23:34:08 -07:00
507 changed files with 2659 additions and 2478 deletions

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

@@ -97,21 +97,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
@@ -123,8 +123,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);
}
@@ -108,8 +110,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

@@ -60,6 +60,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);
@@ -76,6 +77,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);
@@ -87,6 +89,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

View File

@@ -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() {

View File

@@ -35,8 +35,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";
@@ -74,8 +74,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();

View File

@@ -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);

View File

@@ -86,8 +86,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 }));
@@ -98,7 +98,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 {
@@ -118,8 +119,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);

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;