Package io.dropwizard.configuration
Class ConfigurationMetadata
java.lang.Object
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base
io.dropwizard.configuration.ConfigurationMetadata
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWithSerializerProvider,com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper
public class ConfigurationMetadata
extends com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base
A class to get metadata about the properties that are available in a configuration class. It can
be used to get information about the type of the properties. The names are stored as nested paths
(e.g. parent.config.field).
Given the following simple configuration:
public class ExampleConfiguration extends Configuration {
@NotNull
private String name;
private List<String> names = Collections.emptyList();
@JsonProperty
public String getName() {
return name;
}
@JsonProperty
public List<String> getNames() {
return names;
}
}
This leads to the following entries:
name -> {SimpleType} "[simple type, class java.lang.String]"names -> {CollectionType} "[collection type; class java.util.List, contains [simple type, class java.lang.String]]"
Restrictions: The field-tree is only discovered correctly when no inheritance is present. It is hard to discover the correct class, so this sticks to the defaultImpl that is provided.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base -
Field Summary
Fields inherited from class com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base
_provider -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> klass) Create a metadata instance and -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitorexpectObjectFormat(com.fasterxml.jackson.databind.JavaType type) booleanisCollectionOfStrings(String fieldName) Check if a field is a collection of strings.Methods inherited from class com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base
expectAnyFormat, expectArrayFormat, expectBooleanFormat, expectIntegerFormat, expectMapFormat, expectNullFormat, expectNumberFormat, expectStringFormat, getProvider, setProvider
-
Constructor Details
-
ConfigurationMetadata
Create a metadata instance and- Parameters:
mapper- theObjectMapperthat is used to parse the configuration fileklass- the target class of the configuration
-
-
Method Details
-
isCollectionOfStrings
Check if a field is a collection of strings.- Parameters:
fieldName- the field name- Returns:
- true, if the field is a collection of strings
-
expectObjectFormat
public com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor expectObjectFormat(com.fasterxml.jackson.databind.JavaType type) throws com.fasterxml.jackson.databind.JsonMappingException - Specified by:
expectObjectFormatin interfacecom.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper- Overrides:
expectObjectFormatin classcom.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base- Throws:
com.fasterxml.jackson.databind.JsonMappingException
-