Class BaseJacksonConfiguration

java.lang.Object
com.arpnetworking.configuration.BaseConfiguration
com.arpnetworking.configuration.jackson.BaseJacksonConfiguration
All Implemented Interfaces:
Configuration
Direct Known Subclasses:
DynamicConfiguration, StaticConfiguration

public abstract class BaseJacksonConfiguration extends BaseConfiguration
Common base class for Configuration implementations based on Jackson's ObjectMapper.
Author:
Ville Koskela (ville dot koskela at inscopemetrics dot io)
  • Field Details

    • _objectMapper

      protected final com.fasterxml.jackson.databind.ObjectMapper _objectMapper
  • Constructor Details

  • Method Details

    • getProperty

      public Optional<String> getProperty(String name)
      Description copied from interface: Configuration
      Retrieve the value of a particular property by its name.
      Parameters:
      name - The name of the property value to retrieve.
      Returns:
      Returns the property value or Optional.empty() if the property name has not been defined.
    • getPropertyAs

      public <T> Optional<T> getPropertyAs(String name, Class<? extends T> clazz) throws IllegalArgumentException
      Description copied from interface: Configuration
      Generic object accessor.
      Type Parameters:
      T - The type to return.
      Parameters:
      name - The name of the property value to retrieve.
      clazz - The type of the object to instantiate.
      Returns:
      Returns the property value or Optional.empty() if the property name has not been defined.
      Throws:
      IllegalArgumentException - if the value cannot be converted to an instance of T.
    • getAs

      public <T> Optional<T> getAs(Class<? extends T> clazz) throws IllegalArgumentException
      Description copied from interface: Configuration
      Generic object accessor.
      Type Parameters:
      T - The type to return.
      Parameters:
      clazz - The type of the object to instantiate.
      Returns:
      Returns the entire configuration as an instance of T.
      Throws:
      IllegalArgumentException - if the value cannot be converted to an instance of T.
    • getPropertyAs

      public <T> Optional<T> getPropertyAs(String name, Type type) throws IllegalArgumentException
      Description copied from interface: Configuration
      Generic object accessor.
      Type Parameters:
      T - The type to return.
      Parameters:
      name - The name of the property value to retrieve.
      type - The type of the object to instantiate.
      Returns:
      Returns the property value or Optional.empty() if the property name has not been defined.
      Throws:
      IllegalArgumentException - if the value cannot be converted to an instance of T.
    • getAs

      public <T> Optional<T> getAs(Type type) throws IllegalArgumentException
      Description copied from interface: Configuration
      Generic object accessor.
      Type Parameters:
      T - The type to return.
      Parameters:
      type - The type of the object to instantiate.
      Returns:
      Returns the entire configuration as an instance of T.
      Throws:
      IllegalArgumentException - if the value cannot be converted to an instance of T.
    • toLogValue

      public Object toLogValue()
      Description copied from class: BaseConfiguration
      Generate a Steno log compatible representation.
      Overrides:
      toLogValue in class BaseConfiguration
      Returns:
      Steno log compatible representation.
    • getJsonSource

      protected abstract JsonNodeSource getJsonSource()
      Accessor for active root JsonNodeSource instance.
      Returns:
      Instance of JsonNodeSource.