T
- The typepublic abstract class ConfigurationMetadataBuilder<T>
extends java.lang.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 java.lang.String |
buildPropertyPath(T owningType,
T declaringType,
java.lang.String propertyName)
Build a property path for the given declaring type and property name.
|
protected abstract java.lang.String |
buildTypePath(T owningType,
T declaringType)
Variation of
buildPropertyPath(Object, Object, String) for types. |
protected abstract java.lang.String |
buildTypePath(T owningType,
T declaringType,
AnnotationMetadata annotationMetadata)
Variation of
buildPropertyPath(Object, Object, String) for types. |
protected abstract AnnotationMetadata |
getAnnotationMetadata(T type) |
java.util.List<ConfigurationMetadata> |
getConfigurations() |
java.util.List<PropertyMetadata> |
getProperties() |
protected abstract java.lang.String |
getTypeString(T type)
Convert the given type to a string.
|
boolean |
hasMetadata() |
ConfigurationMetadata |
visitProperties(T type,
java.lang.String description)
Visit a
ConfigurationProperties class. |
ConfigurationMetadata |
visitProperties(T type,
java.lang.String description,
AnnotationMetadata annotationMetadata)
Visit a
ConfigurationProperties class. |
PropertyMetadata |
visitProperty(java.lang.String propertyType,
java.lang.String name,
java.lang.String description,
java.lang.String defaultValue)
Visit a configuration property on the last declared properties instance.
|
PropertyMetadata |
visitProperty(T owningType,
T declaringType,
java.lang.String propertyType,
java.lang.String name,
java.lang.String description,
java.lang.String defaultValue)
Visit a configuration property.
|
public java.util.List<PropertyMetadata> getProperties()
public java.util.List<ConfigurationMetadata> getConfigurations()
public boolean hasMetadata()
public ConfigurationMetadata visitProperties(T type, @Nullable java.lang.String description)
ConfigurationProperties
class.type
- The type of the ConfigurationProperties
description
- A descriptionConfigurationMetadata
public ConfigurationMetadata visitProperties(T type, @Nullable java.lang.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, java.lang.String propertyType, java.lang.String name, @Nullable java.lang.String description, @Nullable java.lang.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(java.lang.String propertyType, java.lang.String name, @Nullable java.lang.String description, @Nullable java.lang.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 java.lang.String buildPropertyPath(T owningType, T declaringType, java.lang.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 java.lang.String buildTypePath(T owningType, T declaringType)
buildPropertyPath(Object, Object, String)
for types.owningType
- The owning typedeclaringType
- The typeprotected abstract java.lang.String buildTypePath(T owningType, T declaringType, AnnotationMetadata annotationMetadata)
buildPropertyPath(Object, Object, String)
for types.owningType
- The owning typedeclaringType
- The typeannotationMetadata
- The annotation metadataprotected abstract java.lang.String getTypeString(T type)
type
- The typeprotected abstract AnnotationMetadata getAnnotationMetadata(T type)
type
- The type