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. |
List<ConfigurationMetadata> |
getConfigurations() |
List<PropertyMetadata> |
getProperties() |
protected abstract String |
getTypeString(T type)
Convert the given type to a string.
|
boolean |
hasMetadata() |
ConfigurationMetadata |
visitProperties(T type,
String description)
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.
|
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 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 type