Interface ElementData
- All Known Implementing Classes:
JsonBackedConfigElement,MapBackedElement
public interface ElementData
A generic type-safe reader interface for parameters.
TODO: This should be consolidated with the design of ConfigLoader once the features of these two APIs are stabilized.
The source data for a param reader is intended to be a collection of something, not a single value.
As such, if a single value is provided, an attempt will be made to convert it from JSON if it starts with
object or array notation. If not, the value is assumed to be in the simple ParamsParser form.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasCommonType(Object src) booleancontainsKey(String name) default <T> Tdefault Stringdefault <T> TgetAsCommon(String key) Get the value for the key, but ensure that the type of value that is returned is in one of the sanctionedCOMMON_TYPES.getKeys()default StringgetName()default <T> T
-
Field Details
-
NAME
- See Also:
-
COMMON_TYPES
-
-
Method Details
-
asCommonType
-
get
-
getKeys
-
containsKey
-
getName
-
getGivenName
String getGivenName() -
extractElementName
-
convert
-
get
-
lookup
-
getAsCommon
Get the value for the key, but ensure that the type of value that is returned is in one of the sanctioned
COMMON_TYPES.If possible, the value provided should be a wrapper type around the actual backing type, such that mutability is preserved.
If the backing type is a structured type object graph which defies direct conversion to one of the types above, then an error should be thrown.
If the type is a collection type, then type conversion should be provided all the way down to each primitive value.
If no value by the given name exists, the null should be returned.
- Parameters:
key- The key of the value to retrieve- Returns:
- The value as a Java primitive, Boxed primitive, or Set, List, or Map of String to Object.
-