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 Details

  • Method Details

    • asCommonType

      static Optional<Object> asCommonType(Object src)
    • get

      Object get(String name)
    • getKeys

      Set<String> getKeys()
    • containsKey

      boolean containsKey(String name)
    • getName

      default String getName()
    • getGivenName

      String getGivenName()
    • extractElementName

      default String extractElementName()
    • convert

      default <T> T convert(Object input, Class<T> type)
    • get

      default <T> T get(String name, Class<T> type)
    • lookup

      default <T> T lookup(String name, Class<T> type)
    • getAsCommon

      Object getAsCommon(String key)

      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.