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.BaseA 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.
-
-
Constructor Summary
Constructors Constructor Description ConfigurationMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> klass)Create a metadata instance and
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitorexpectObjectFormat(com.fasterxml.jackson.databind.JavaType type)booleanisCollectionOfStrings(String fieldName)Check if a field is a collection of strings.
-
-
-
Constructor Detail
-
ConfigurationMetadata
public ConfigurationMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> klass)Create a metadata instance and- Parameters:
mapper- theObjectMapperthat is used to parse the configuration fileklass- the target class of the configuration
-
-
Method Detail
-
isCollectionOfStrings
public boolean isCollectionOfStrings(String fieldName)
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
-
-