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

    Constructors
    Constructor
    Description
    ConfigurationMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> klass)
    Create a metadata instance and
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor
    expectObjectFormat(com.fasterxml.jackson.databind.JavaType type)
     
    boolean
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigurationMetadata

      public ConfigurationMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> klass)
      Create a metadata instance and
      Parameters:
      mapper - the ObjectMapper that is used to parse the configuration file
      klass - the target class of the configuration
  • Method Details

    • 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:
      expectObjectFormat in interface com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper
      Overrides:
      expectObjectFormat in class com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.Base
      Throws:
      com.fasterxml.jackson.databind.JsonMappingException