Commit f2af8b30 authored by Phillip Webb's avatar Phillip Webb

Code formatting

parent fe5800f8
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
<main.basedir>${basedir}/../..</main.basedir> <main.basedir>${basedir}/../..</main.basedir>
</properties> </properties>
<dependencies> <dependencies>
<!-- Runs in the compiler so dependencies should stick to the bare minimum --> <!-- Compile (should stick to the bare minimum) -->
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
</dependency> </dependency>
<!-- Test -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
......
...@@ -207,8 +207,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor ...@@ -207,8 +207,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private void processLombokTypes(String prefix, TypeElement element, private void processLombokTypes(String prefix, TypeElement element,
TypeElementMembers members, Map<String, Object> fieldValues) { TypeElementMembers members, Map<String, Object> fieldValues) {
for (Map.Entry<String, VariableElement> entry : members.getFields() for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
.entrySet()) {
String name = entry.getKey(); String name = entry.getKey();
VariableElement field = entry.getValue(); VariableElement field = entry.getValue();
if (!isLombokField(field, element)) { if (!isLombokField(field, element)) {
...@@ -241,10 +240,10 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor ...@@ -241,10 +240,10 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
} }
private boolean hasLombokSetter(VariableElement field, TypeElement element) { private boolean hasLombokSetter(VariableElement field, TypeElement element) {
return !field.getModifiers().contains(Modifier.FINAL) && ( return !field.getModifiers().contains(Modifier.FINAL)
hasAnnotation(field, LOMBOK_SETTER_ANNOTATION) && (hasAnnotation(field, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION) || hasAnnotation(element, LOMBOK_SETTER_ANNOTATION) || hasAnnotation(
|| hasAnnotation(element, LOMBOK_DATA_ANNOTATION)); element, LOMBOK_DATA_ANNOTATION));
} }
private void processNestedTypes(String prefix, TypeElement element, private void processNestedTypes(String prefix, TypeElement element,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException; import java.io.IOException;
import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
...@@ -24,10 +25,9 @@ import javax.lang.model.SourceVersion; ...@@ -24,10 +25,9 @@ import javax.lang.model.SourceVersion;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata; import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
import org.springframework.boot.configurationsample.lombok.LombokSimpleDataProperties;
import org.springframework.boot.configurationsample.lombok.LombokExplicitProperties; import org.springframework.boot.configurationsample.lombok.LombokExplicitProperties;
import org.springframework.boot.configurationsample.lombok.LombokSimpleDataProperties;
import org.springframework.boot.configurationsample.lombok.LombokSimpleProperties; import org.springframework.boot.configurationsample.lombok.LombokSimpleProperties;
import org.springframework.boot.configurationsample.method.EmptyTypeMethodConfig; import org.springframework.boot.configurationsample.method.EmptyTypeMethodConfig;
import org.springframework.boot.configurationsample.method.InvalidMethodConfig; import org.springframework.boot.configurationsample.method.InvalidMethodConfig;
...@@ -307,20 +307,17 @@ public class ConfigurationMetadataAnnotationProcessorTests { ...@@ -307,20 +307,17 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class, "explicit"); assertSimpleLombokProperties(metadata, LombokExplicitProperties.class, "explicit");
} }
private void assertSimpleLombokProperties(ConfigurationMetadata metadata, Class<?> source, String prefix) { private void assertSimpleLombokProperties(ConfigurationMetadata metadata,
Class<?> source, String prefix) {
assertThat(metadata, containsGroup(prefix).fromSource(source)); assertThat(metadata, containsGroup(prefix).fromSource(source));
assertThat(metadata, not(containsProperty(prefix + ".id"))); assertThat(metadata, not(containsProperty(prefix + ".id")));
assertThat( assertThat(metadata,
metadata, containsProperty(prefix + ".name", String.class).fromSource(source)
containsProperty(prefix + ".name", String.class)
.fromSource(source)
.withDescription("Name description.")); .withDescription("Name description."));
assertThat(metadata, containsProperty(prefix + ".description")); assertThat(metadata, containsProperty(prefix + ".description"));
assertThat(metadata, containsProperty(prefix + ".counter")); assertThat(metadata, containsProperty(prefix + ".counter"));
assertThat(metadata, assertThat(metadata, containsProperty(prefix + ".number").fromSource(source)
containsProperty(prefix + ".number").fromSource(source) .withDefaultValue(is(0)).withDeprecated());
.withDefaultValue(is(0))
.withDeprecated());
assertThat(metadata, containsProperty(prefix + ".items")); assertThat(metadata, containsProperty(prefix + ".items"));
assertThat(metadata, not(containsProperty(prefix + ".ignored"))); assertThat(metadata, not(containsProperty(prefix + ".ignored")));
} }
...@@ -331,7 +328,7 @@ public class ConfigurationMetadataAnnotationProcessorTests { ...@@ -331,7 +328,7 @@ public class ConfigurationMetadataAnnotationProcessorTests {
return processor.getMetadata(); return processor.getMetadata();
} }
@SupportedAnnotationTypes({"*"}) @SupportedAnnotationTypes({ "*" })
@SupportedSourceVersion(SourceVersion.RELEASE_6) @SupportedSourceVersion(SourceVersion.RELEASE_6)
private static class TestConfigurationMetadataAnnotationProcessor extends private static class TestConfigurationMetadataAnnotationProcessor extends
ConfigurationMetadataAnnotationProcessor { ConfigurationMetadataAnnotationProcessor {
......
...@@ -38,22 +38,28 @@ public class LombokExplicitProperties { ...@@ -38,22 +38,28 @@ public class LombokExplicitProperties {
/** /**
* Name description. * Name description.
*/ */
@Getter @Setter @Getter
@Setter
private String name; private String name;
@Getter @Setter @Getter
@Setter
private String description; private String description;
@Getter @Setter @Getter
@Setter
private Integer counter; private Integer counter;
@Deprecated @Getter @Setter @Deprecated
@Getter
@Setter
private Integer number = 0; private Integer number = 0;
@Getter @Getter
private final List<String> items = new ArrayList<String>(); private final List<String> items = new ArrayList<String>();
// Should be ignored if no annotation is set // Should be ignored if no annotation is set
@SuppressWarnings("unused")
private String ignored; private String ignored;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment