Class BaseJacksonConfiguration
java.lang.Object
com.arpnetworking.configuration.BaseConfiguration
com.arpnetworking.configuration.jackson.BaseJacksonConfiguration
- All Implemented Interfaces:
Configuration
- Direct Known Subclasses:
DynamicConfiguration
,StaticConfiguration
Common base class for
Configuration
implementations based on
Jackson's ObjectMapper
.- Author:
- Ville Koskela (ville dot koskela at inscopemetrics dot io)
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
BaseJacksonConfiguration.Builder<T extends BaseJacksonConfiguration.Builder<?,
?>, S extends Configuration> Builder
implementation forBaseJacksonConfiguration
. -
Field Summary
Modifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.databind.ObjectMapper
-
Constructor Summary
ModifierConstructorDescriptionprotected
BaseJacksonConfiguration
(BaseJacksonConfiguration.Builder<?, ?> builder) Protected constructor. -
Method Summary
Modifier and TypeMethodDescription<T> Optional<T>
Generic object accessor.<T> Optional<T>
Generic object accessor.protected abstract JsonNodeSource
Accessor for active rootJsonNodeSource
instance.getProperty
(String name) Retrieve the value of a particular property by its name.<T> Optional<T>
getPropertyAs
(String name, Class<? extends T> clazz) Generic object accessor.<T> Optional<T>
getPropertyAs
(String name, Type type) Generic object accessor.Generate a Steno log compatible representation.Methods inherited from class com.arpnetworking.configuration.BaseConfiguration
getAs, getAs, getProperty, getPropertyAs, getPropertyAs, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsInteger, getPropertyAsInteger, getPropertyAsLong, getPropertyAsLong, getPropertyAsShort, getPropertyAsShort, getRequiredAs, getRequiredAs, getRequiredProperty, getRequiredPropertyAs, getRequiredPropertyAs, getRequiredPropertyAsBoolean, getRequiredPropertyAsDouble, getRequiredPropertyAsFloat, getRequiredPropertyAsInteger, getRequiredPropertyAsLong, getRequiredPropertyAsShort, toString
-
Field Details
-
_objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper _objectMapper
-
-
Constructor Details
-
BaseJacksonConfiguration
Protected constructor.- Parameters:
builder
- TheBaseJacksonConfiguration.Builder
instance to construct from.
-
-
Method Details
-
getProperty
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 ofT
.
-
getAs
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 ofT
.
-
getPropertyAs
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 ofT
.
-
getAs
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 ofT
.
-
toLogValue
Description copied from class:BaseConfiguration
Generate a Steno log compatible representation.- Overrides:
toLogValue
in classBaseConfiguration
- Returns:
- Steno log compatible representation.
-
getJsonSource
Accessor for active rootJsonNodeSource
instance.- Returns:
- Instance of
JsonNodeSource
.
-