T
- The typepublic abstract class ConfigurationMetadataBuilder<T> extends Object
A builder for producing metadata for the available ConfigurationProperties
.
This data can then be subsequently written to a format readable by IDEs (like spring-configuration-metadata.json for example).
Constructor and Description |
---|
ConfigurationMetadataBuilder() |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
buildPropertyPath(T owningType,
T declaringType,
String propertyName)
Build a property path for the given declaring type and property name.
|
protected abstract String |
buildTypePath(T owningType,
T declaringType)
Variation of
buildPropertyPath(Object, Object, String) for types. |
protected abstract String |
buildTypePath(T owningType,
T declaringType,
AnnotationMetadata annotationMetadata)
Variation of
buildPropertyPath(Object, Object, String) for types. |
protected abstract AnnotationMetadata |
getAnnotationMetadata(T type) |
static Optional<ConfigurationMetadataBuilder<?>> |
getConfigurationMetadataBuilder()
Obtains the currently active metadata builder.
|
List<ConfigurationMetadata> |
getConfigurations() |
abstract Element[] |
getOriginatingElements() |
List<PropertyMetadata> |
getProperties() |
protected abstract String |
getTypeString(T type)
Convert the given type to a string.
|
boolean |
hasMetadata() |
static void |
setConfigurationMetadataBuilder(ConfigurationMetadataBuilder<?> builder)
Sets or clears the current
ConfigurationMetadataBuilder . |
ConfigurationMetadata |
visitProperties(T type,
String description)
Visit a
ConfigurationProperties class. |
ConfigurationMetadata |
visitProperties(T type,
String description,
AnnotationMetadata annotationMetadata)
Visit a
ConfigurationProperties class. |
PropertyMetadata |
visitProperty(String propertyType,
String name,
String description,
String defaultValue)
Visit a configuration property on the last declared properties instance.
|
PropertyMetadata |
visitProperty(T owningType,
T declaringType,
String propertyType,
String name,
String description,
String defaultValue)
Visit a configuration property.
|
@NonNull public abstract Element[] getOriginatingElements()
public List<PropertyMetadata> getProperties()
public List<ConfigurationMetadata> getConfigurations()
public boolean hasMetadata()
public ConfigurationMetadata visitProperties(T type, @Nullable String description)
ConfigurationProperties
class.type
- The type of the ConfigurationProperties
description
- A descriptionConfigurationMetadata
public ConfigurationMetadata visitProperties(T type, @Nullable String description, @NonNull AnnotationMetadata annotationMetadata)
ConfigurationProperties
class.type
- The type of the ConfigurationProperties
description
- A descriptionannotationMetadata
- the annotation metadataConfigurationMetadata
public PropertyMetadata visitProperty(T owningType, T declaringType, String propertyType, String name, @Nullable String description, @Nullable String defaultValue)
owningType
- The type that owns the propertydeclaringType
- The declaring type of the propertypropertyType
- The property typename
- The property namedescription
- A description for the propertydefaultValue
- The default value of the property (only used for constant values such as strings, numbers,
enums etc.)public PropertyMetadata visitProperty(String propertyType, String name, @Nullable String description, @Nullable String defaultValue)
propertyType
- The property typename
- The property namedescription
- A description for the propertydefaultValue
- The default value of the property (only used for constant values such as strings, numbers,
enums etc.)protected abstract String buildPropertyPath(T owningType, T declaringType, String propertyName)
Build a property path for the given declaring type and property name.
For ConfigurationProperties
that path is a property is
established by looking at the value of the ConfigurationProperties
and
then calculating the path based on the inheritance tree.
For example consider the following classes:
@ConfigurationProperties("parent")
public class ParentProperties {
String foo;
}
@ConfigurationProperties("child")
public class ChildProperties extends ParentProperties {
String bar;
}
The path of the property foo
will be "parent.foo" whilst the path of the property bar
will
be "parent.child.bar" factoring in the class hierarchy
Inner classes hierarchies are also taken into account
owningType
- The owning typedeclaringType
- The declaring typepropertyName
- The property nameprotected abstract String buildTypePath(T owningType, T declaringType)
buildPropertyPath(Object, Object, String)
for types.owningType
- The owning typedeclaringType
- The typeprotected abstract String buildTypePath(T owningType, T declaringType, AnnotationMetadata annotationMetadata)
buildPropertyPath(Object, Object, String)
for types.owningType
- The owning typedeclaringType
- The typeannotationMetadata
- The annotation metadataprotected abstract String getTypeString(T type)
type
- The typeprotected abstract AnnotationMetadata getAnnotationMetadata(T type)
type
- The typepublic static Optional<ConfigurationMetadataBuilder<?>> getConfigurationMetadataBuilder()
public static void setConfigurationMetadataBuilder(@Nullable ConfigurationMetadataBuilder<?> builder)
ConfigurationMetadataBuilder
.builder
- the builder