Rename @ImportConfigurationPropertiesBean
Rename `@ImportConfigurationPropertiesBean` to `@ConfigurationPropertiesImport`. Closes gh-23172
This commit is contained in:
@@ -80,9 +80,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
|
||||
static final String NAME_ANNOTATION = "org.springframework.boot.context.properties.bind.Name";
|
||||
|
||||
static final String IMPORT_CONFIGURATION_PROPERTIES_BEAN_ANNOATION = "org.springframework.boot.context.properties.ImportConfigurationPropertiesBean";
|
||||
static final String CONFIGURATION_PROPERTIES_IMPORT_ANNOATION = "org.springframework.boot.context.properties.ConfigurationPropertiesImport";
|
||||
|
||||
static final String IMPORT_CONFIGURATION_PROPERTIES_BEANS_ANNOATION = "org.springframework.boot.context.properties.ImportConfigurationPropertiesBeans";
|
||||
static final String CONFIGURATION_PROPERTIES_IMPORTS_ANNOATION = "org.springframework.boot.context.properties.ConfigurationPropertiesImports";
|
||||
|
||||
private static final Set<String> SUPPORTED_OPTIONS = Collections
|
||||
.unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION));
|
||||
@@ -125,12 +125,12 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
return NAME_ANNOTATION;
|
||||
}
|
||||
|
||||
protected String importConfigurationPropertiesBeanAnnotation() {
|
||||
return IMPORT_CONFIGURATION_PROPERTIES_BEAN_ANNOATION;
|
||||
protected String configurationPropertiesImportAnnotation() {
|
||||
return CONFIGURATION_PROPERTIES_IMPORT_ANNOATION;
|
||||
}
|
||||
|
||||
protected String importConfigurationPropertiesBeansAnnotation() {
|
||||
return IMPORT_CONFIGURATION_PROPERTIES_BEANS_ANNOATION;
|
||||
protected String configurationPropertiesImportsAnnotation() {
|
||||
return CONFIGURATION_PROPERTIES_IMPORTS_ANNOATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,8 +151,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
this.metadataEnv = new MetadataGenerationEnvironment(env, configurationPropertiesAnnotation(),
|
||||
nestedConfigurationPropertyAnnotation(), deprecatedConfigurationPropertyAnnotation(),
|
||||
constructorBindingAnnotation(), defaultValueAnnotation(), endpointAnnotation(),
|
||||
readOperationAnnotation(), nameAnnotation(), importConfigurationPropertiesBeanAnnotation(),
|
||||
importConfigurationPropertiesBeansAnnotation());
|
||||
readOperationAnnotation(), nameAnnotation(), configurationPropertiesImportAnnotation(),
|
||||
configurationPropertiesImportsAnnotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +160,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
this.metadataCollector.processing(roundEnv);
|
||||
processConfigurationProperties(roundEnv);
|
||||
processEndpoint(roundEnv);
|
||||
processImportConfigurationPropertiesBean(roundEnv);
|
||||
processConfigurationPropertiesImport(roundEnv);
|
||||
if (roundEnv.processingOver()) {
|
||||
try {
|
||||
writeMetaData();
|
||||
@@ -188,22 +188,22 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
}
|
||||
}
|
||||
|
||||
private void processImportConfigurationPropertiesBean(RoundEnvironment roundEnv) {
|
||||
TypeElement importConfigurationPropertiesBeanType = this.metadataEnv
|
||||
.getImportConfigurationPropertiesBeanAnnotationElement();
|
||||
TypeElement importConfigurationPropertiesBeansType = this.metadataEnv
|
||||
.getImportConfigurationPropertiesBeansAnnotationElement();
|
||||
if (importConfigurationPropertiesBeanType == null && importConfigurationPropertiesBeansType == null) {
|
||||
private void processConfigurationPropertiesImport(RoundEnvironment roundEnv) {
|
||||
TypeElement configurationPropertiesImportType = this.metadataEnv
|
||||
.getConfigurationPropertiesImportAnnotationElement();
|
||||
TypeElement configurationPropertiesImportsType = this.metadataEnv
|
||||
.getConfigurationPropertiesImportsAnnotationElement();
|
||||
if (configurationPropertiesImportType == null && configurationPropertiesImportsType == null) {
|
||||
return;
|
||||
}
|
||||
Set<Element> elements = new LinkedHashSet<>();
|
||||
if (importConfigurationPropertiesBeanType != null) {
|
||||
elements.addAll(roundEnv.getElementsAnnotatedWith(importConfigurationPropertiesBeanType));
|
||||
if (configurationPropertiesImportType != null) {
|
||||
elements.addAll(roundEnv.getElementsAnnotatedWith(configurationPropertiesImportType));
|
||||
}
|
||||
if (importConfigurationPropertiesBeansType != null) {
|
||||
elements.addAll(roundEnv.getElementsAnnotatedWith(importConfigurationPropertiesBeansType));
|
||||
if (configurationPropertiesImportsType != null) {
|
||||
elements.addAll(roundEnv.getElementsAnnotatedWith(configurationPropertiesImportsType));
|
||||
}
|
||||
elements.forEach(this::processImportConfigurationPropertiesBean);
|
||||
elements.forEach(this::processConfigurationPropertiesImport);
|
||||
}
|
||||
|
||||
private Map<Element, List<Element>> getElementsAnnotatedOrMetaAnnotatedWith(RoundEnvironment roundEnv,
|
||||
@@ -314,13 +314,13 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
}
|
||||
}
|
||||
|
||||
private void processImportConfigurationPropertiesBean(Element element) {
|
||||
this.metadataEnv.getImportConfigurationPropertiesBeanAnnotations(element)
|
||||
.forEach(this::processImportConfigurationPropertiesBean);
|
||||
private void processConfigurationPropertiesImport(Element element) {
|
||||
this.metadataEnv.getConfigurationPropertiesImportAnnotations(element)
|
||||
.forEach(this::processConfigurationPropertiesImport);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void processImportConfigurationPropertiesBean(AnnotationMirror annotation) {
|
||||
private void processConfigurationPropertiesImport(AnnotationMirror annotation) {
|
||||
String prefix = getPrefix(annotation);
|
||||
List<TypeMirror> types = (List<TypeMirror>) this.metadataEnv.getAnnotationElementValues(annotation).get("type");
|
||||
for (TypeMirror type : types) {
|
||||
|
||||
@@ -97,15 +97,15 @@ class MetadataGenerationEnvironment {
|
||||
|
||||
private final String nameAnnotation;
|
||||
|
||||
private final String importConfigurationPropertiesBeanAnnotation;
|
||||
private final String configurationPropertiesImportAnnotation;
|
||||
|
||||
private final String importConfigurationPropertiesBeansAnnotation;
|
||||
private final String configurationPropertiesImportsAnnotation;
|
||||
|
||||
MetadataGenerationEnvironment(ProcessingEnvironment environment, String configurationPropertiesAnnotation,
|
||||
String nestedConfigurationPropertyAnnotation, String deprecatedConfigurationPropertyAnnotation,
|
||||
String constructorBindingAnnotation, String defaultValueAnnotation, String endpointAnnotation,
|
||||
String readOperationAnnotation, String nameAnnotation, String importConfigurationPropertiesBeanAnnotation,
|
||||
String importConfigurationPropertiesBeansAnnotation) {
|
||||
String readOperationAnnotation, String nameAnnotation, String configurationPropertiesImportAnnotation,
|
||||
String configurationPropertiesImportsAnnotation) {
|
||||
this.typeUtils = new TypeUtils(environment);
|
||||
this.elements = environment.getElementUtils();
|
||||
this.messager = environment.getMessager();
|
||||
@@ -118,8 +118,8 @@ class MetadataGenerationEnvironment {
|
||||
this.endpointAnnotation = endpointAnnotation;
|
||||
this.readOperationAnnotation = readOperationAnnotation;
|
||||
this.nameAnnotation = nameAnnotation;
|
||||
this.importConfigurationPropertiesBeanAnnotation = importConfigurationPropertiesBeanAnnotation;
|
||||
this.importConfigurationPropertiesBeansAnnotation = importConfigurationPropertiesBeansAnnotation;
|
||||
this.configurationPropertiesImportAnnotation = configurationPropertiesImportAnnotation;
|
||||
this.configurationPropertiesImportsAnnotation = configurationPropertiesImportsAnnotation;
|
||||
}
|
||||
|
||||
private static FieldValuesParser resolveFieldValuesParser(ProcessingEnvironment env) {
|
||||
@@ -265,12 +265,12 @@ class MetadataGenerationEnvironment {
|
||||
return this.elements.getTypeElement(this.configurationPropertiesAnnotation);
|
||||
}
|
||||
|
||||
TypeElement getImportConfigurationPropertiesBeanAnnotationElement() {
|
||||
return this.elements.getTypeElement(this.importConfigurationPropertiesBeanAnnotation);
|
||||
TypeElement getConfigurationPropertiesImportAnnotationElement() {
|
||||
return this.elements.getTypeElement(this.configurationPropertiesImportAnnotation);
|
||||
}
|
||||
|
||||
TypeElement getImportConfigurationPropertiesBeansAnnotationElement() {
|
||||
return this.elements.getTypeElement(this.importConfigurationPropertiesBeansAnnotation);
|
||||
TypeElement getConfigurationPropertiesImportsAnnotationElement() {
|
||||
return this.elements.getTypeElement(this.configurationPropertiesImportsAnnotation);
|
||||
}
|
||||
|
||||
AnnotationMirror getConfigurationPropertiesAnnotation(Element element) {
|
||||
@@ -297,13 +297,13 @@ class MetadataGenerationEnvironment {
|
||||
return getAnnotation(element, this.nameAnnotation);
|
||||
}
|
||||
|
||||
List<AnnotationMirror> getImportConfigurationPropertiesBeanAnnotations(Element element) {
|
||||
List<AnnotationMirror> getConfigurationPropertiesImportAnnotations(Element element) {
|
||||
List<AnnotationMirror> annotations = new ArrayList<>();
|
||||
AnnotationMirror importBean = getAnnotation(element, this.importConfigurationPropertiesBeanAnnotation);
|
||||
AnnotationMirror importBean = getAnnotation(element, this.configurationPropertiesImportAnnotation);
|
||||
if (importBean != null) {
|
||||
annotations.add(importBean);
|
||||
}
|
||||
AnnotationMirror importBeans = getAnnotation(element, this.importConfigurationPropertiesBeansAnnotation);
|
||||
AnnotationMirror importBeans = getAnnotation(element, this.configurationPropertiesImportsAnnotation);
|
||||
if (importBeans != null) {
|
||||
AnnotationValue value = importBeans.getElementValues().values().iterator().next();
|
||||
for (Object contained : (List<?>) value.getValue()) {
|
||||
|
||||
@@ -50,7 +50,7 @@ class PropertyDescriptorResolver {
|
||||
* factory method}, if any.
|
||||
* @param type the target type
|
||||
* @param fromImport it the type was imported via a
|
||||
* {@code @ImportConfigurationPropertiesBean}
|
||||
* {@code @ConfigurationPropertiesImport}
|
||||
* @param factoryMethod the method that triggered the metadata for that {@code type}
|
||||
* or {@code null}
|
||||
* @return the candidate properties for metadata generation
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
|
||||
import org.springframework.boot.configurationprocessor.metadata.Metadata;
|
||||
import org.springframework.boot.configurationsample.ImportConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.ImportConfigurationPropertiesBeans;
|
||||
import org.springframework.boot.configurationsample.ConfigurationPropertiesImport;
|
||||
import org.springframework.boot.configurationsample.ConfigurationPropertiesImports;
|
||||
import org.springframework.boot.configurationsample.importbean.ImportJavaBeanConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.importbean.ImportMultipleTypeConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.importbean.ImportRepeatedConfigurationPropertiesBean;
|
||||
@@ -32,8 +32,8 @@ import org.springframework.boot.configurationsample.importbean.ImportedValueObje
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ImportConfigurationPropertiesBean} and
|
||||
* {@link ImportConfigurationPropertiesBeans}.
|
||||
* Tests for {@link ConfigurationPropertiesImport} and
|
||||
* {@link ConfigurationPropertiesImports}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
||||
@@ -40,8 +40,8 @@ class MetadataGenerationEnvironmentFactory implements Function<ProcessingEnviron
|
||||
TestConfigurationMetadataAnnotationProcessor.ENDPOINT_ANNOTATION,
|
||||
TestConfigurationMetadataAnnotationProcessor.READ_OPERATION_ANNOTATION,
|
||||
TestConfigurationMetadataAnnotationProcessor.NAME_ANNOTATION,
|
||||
TestConfigurationMetadataAnnotationProcessor.IMPORT_CONFIGURATION_PROPERTIES_BEAN_ANNOATION,
|
||||
TestConfigurationMetadataAnnotationProcessor.IMPORT_CONFIGURATION_PROPERTIES_BEANS_ANNOATION);
|
||||
TestConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_IMPORT_ANNOATION,
|
||||
TestConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_IMPORTS_ANNOATION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class TestConfigurationMetadataAnnotationProcessor extends ConfigurationM
|
||||
|
||||
public static final String NAME_ANNOTATION = "org.springframework.boot.configurationsample.Name";
|
||||
|
||||
public static final String IMPORT_CONFIGURATION_PROPERTIES_BEAN_ANNOATION = "org.springframework.boot.configurationsample.ImportConfigurationPropertiesBean";
|
||||
public static final String CONFIGURATION_PROPERTIES_IMPORT_ANNOATION = "org.springframework.boot.configurationsample.ConfigurationPropertiesImport";
|
||||
|
||||
public static final String IMPORT_CONFIGURATION_PROPERTIES_BEANS_ANNOATION = "org.springframework.boot.configurationsample.ImportConfigurationPropertiesBeans";
|
||||
public static final String CONFIGURATION_PROPERTIES_IMPORTS_ANNOATION = "org.springframework.boot.configurationsample.ConfigurationPropertiesImports";
|
||||
|
||||
private ConfigurationMetadata metadata;
|
||||
|
||||
@@ -110,13 +110,13 @@ public class TestConfigurationMetadataAnnotationProcessor extends ConfigurationM
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String importConfigurationPropertiesBeanAnnotation() {
|
||||
return IMPORT_CONFIGURATION_PROPERTIES_BEAN_ANNOATION;
|
||||
protected String configurationPropertiesImportAnnotation() {
|
||||
return CONFIGURATION_PROPERTIES_IMPORT_ANNOATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String importConfigurationPropertiesBeansAnnotation() {
|
||||
return IMPORT_CONFIGURATION_PROPERTIES_BEANS_ANNOATION;
|
||||
protected String configurationPropertiesImportsAnnotation() {
|
||||
return CONFIGURATION_PROPERTIES_IMPORTS_ANNOATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.lang.annotation.Target;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Alternative to Spring Boot's {@code ImportConfigurationPropertiesBean} for testing
|
||||
* (removes the need for a dependency on the real annotation).
|
||||
* Alternative to Spring Boot's {@code ConfigurationPropertiesImport} for testing (removes
|
||||
* the need for a dependency on the real annotation).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@@ -35,8 +35,8 @@ import org.springframework.core.annotation.AliasFor;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@ConfigurationProperties
|
||||
@Repeatable(ImportConfigurationPropertiesBeans.class)
|
||||
public @interface ImportConfigurationPropertiesBean {
|
||||
@Repeatable(ConfigurationPropertiesImports.class)
|
||||
public @interface ConfigurationPropertiesImport {
|
||||
|
||||
Class<?>[] type();
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Alternative to Spring Boot's {@code ImportConfigurationPropertiesBeans} for testing
|
||||
* Alternative to Spring Boot's {@code ConfigurationPropertiesImports} for testing
|
||||
* (removes the need for a dependency on the real annotation).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
@@ -31,8 +31,8 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ImportConfigurationPropertiesBeans {
|
||||
public @interface ConfigurationPropertiesImports {
|
||||
|
||||
ImportConfigurationPropertiesBean[] value();
|
||||
ConfigurationPropertiesImport[] value();
|
||||
|
||||
}
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.boot.configurationsample.importbean;
|
||||
|
||||
import org.springframework.boot.configurationsample.ImportConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.ConfigurationPropertiesImport;
|
||||
|
||||
/**
|
||||
* An import of a java bean.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ImportConfigurationPropertiesBean(type = ImportedJavaBean.class, prefix = "importbean")
|
||||
@ConfigurationPropertiesImport(type = ImportedJavaBean.class, prefix = "importbean")
|
||||
public class ImportJavaBeanConfigurationPropertiesBean {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.boot.configurationsample.importbean;
|
||||
|
||||
import org.springframework.boot.configurationsample.ImportConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.ConfigurationPropertiesImport;
|
||||
|
||||
/**
|
||||
* An import of a java bean and a value object.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ImportConfigurationPropertiesBean(type = { ImportedJavaBean.class, ImportedValueObject.class }, prefix = "importbean")
|
||||
@ConfigurationPropertiesImport(type = { ImportedJavaBean.class, ImportedValueObject.class }, prefix = "importbean")
|
||||
public class ImportMultipleTypeConfigurationPropertiesBean {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package org.springframework.boot.configurationsample.importbean;
|
||||
|
||||
import org.springframework.boot.configurationsample.ImportConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.ConfigurationPropertiesImport;
|
||||
|
||||
/**
|
||||
* An import of a java bean and a value object.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ImportConfigurationPropertiesBean(type = ImportedJavaBean.class, prefix = "jb")
|
||||
@ImportConfigurationPropertiesBean(type = ImportedValueObject.class, prefix = "vo")
|
||||
@ConfigurationPropertiesImport(type = ImportedJavaBean.class, prefix = "jb")
|
||||
@ConfigurationPropertiesImport(type = ImportedValueObject.class, prefix = "vo")
|
||||
public class ImportRepeatedConfigurationPropertiesBean {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.boot.configurationsample.importbean;
|
||||
|
||||
import org.springframework.boot.configurationsample.ImportConfigurationPropertiesBean;
|
||||
import org.springframework.boot.configurationsample.ConfigurationPropertiesImport;
|
||||
|
||||
/**
|
||||
* An import of a value object.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ImportConfigurationPropertiesBean(type = ImportedValueObject.class, prefix = "importbean")
|
||||
@ConfigurationPropertiesImport(type = ImportedValueObject.class, prefix = "importbean")
|
||||
public class ImportValueObjectConfigurationPropertiesBean {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user