Interface StructuredMap

All Known Implementing Classes:
StructuredDictionary, StructuredParameters

public interface StructuredMap
Shared interface for StructuredParameters and StructuredDictionary. Contains methods for converting structured dictionaries to Java Map containing Java plain objects.
  • Method Details

    • itemMap

      <T extends StructuredItem> Map<String,T> itemMap()
      Returns Map of Structured Items stored in this Dictionary or Parameters. Keys or returned map correspond to Dictionary or Parameters keys. Values are StructuredItem members of Dictionary or Parameters.
      Type Parameters:
      T - Specific Item class if needed. No type check is performed, only simple casting.
      Returns:
      Underlying map of StructuredItem objects
    • itemMap

      default <T extends StructuredItem> Map<String,T> itemMap(Class<T> itemClass)
      Returns Map of Structured Items stored in this Dictionary or Parameters.

      Similar to itemMap() ()}, but class of map values is provided as method argument rather than "generic type argument", e.g. myDict.itemMap(StructuredInteger.class) instead of myDict.<StructuredInteger>itemMap().

      Type Parameters:
      T - Type of map values
      Parameters:
      itemClass - Class of map values. No type check is performed, only simple casting.
      Returns:
      Underlying map of StructuredItem objects
    • keySet

      default Set<String> keySet()
      Returns the key set of underlying map
      Returns:
      Map's key set
      See Also:
    • entrySet

      default <T extends StructuredItem> Set<Map.Entry<String,T>> entrySet()
      Returns entry set of underlying map
      Type Parameters:
      T - Specific Item class if needed. No type check is performed, only simple casting.
      Returns:
      Map's entry set
      See Also:
    • entrySet

      default <T extends StructuredItem> Set<Map.Entry<String,T>> entrySet(Class<T> itemClass)
      Returns entry set of underlying map
      Type Parameters:
      T - Type of map values
      Parameters:
      itemClass - Class of map values. No type check is performed, only simple casting.
      Returns:
      Map's entry set
      See Also:
    • values

      default <T extends StructuredItem> List<T> values()
      Returns values of underlying map

      Contrary to Map.values(), a List is returned rather than Collection. It's because order of Structured Parameters and Dictionary members is defined.

      Type Parameters:
      T - Specific Item class if needed. No type check is performed, only simple casting.
      Returns:
      Map's values
      See Also:
    • values

      default <T extends StructuredItem> List<T> values(Class<T> itemClass)
      Returns values of underlying map

      Contrary to Map.values(), a List is returned rather than Collection. It's because order of Structured Parameters and Dictionary members is defined.

      Type Parameters:
      T - Type of map values
      Parameters:
      itemClass - Class of map values. No type check is performed, only simple casting.
      Returns:
      Map's values
      See Also:
    • isEmpty

      default boolean isEmpty()
      Returns true if underlying map contains no elements
      Returns:
      True if map contains no elements
    • stringMap

      default Map<String,String> stringMap()
      Returns this map with Structured Item values converted to String objects.
      Returns:
      Map with values converted to String
      See Also:
    • boolMap

      default Map<String,Boolean> boolMap()
      Returns this map with Structured Item values converted to Boolean objects. This map must contain StructuredBoolean values only.
      Returns:
      Map with values converted to Boolean
      Throws:
      UnsupportedOperationException - Thrown if this map contains non-StructuredBoolean values
    • intMap

      default Map<String,Integer> intMap()
      Returns this map with Structured Item values converted to Integer objects. This map must contain StructuredInteger values only.

      (int) cast is used internally, which means that returned value will be wrong for item values smaller than Integer.MIN_VALUE or grater than Integer.MAX_VALUE.

      Returns:
      Map with values converted to Integer
      Throws:
      UnsupportedOperationException - Thrown if this map contains non-StructuredInteger values
    • longMap

      default Map<String,Long> longMap()
      Returns this map with Structured Item values converted to Long objects. This map must contain StructuredInteger values only.
      Returns:
      Map with values converted to Long
      Throws:
      UnsupportedOperationException - Thrown if this map contains non-StructuredInteger values
    • bigDecimalMap

      default Map<String,BigDecimal> bigDecimalMap()
      Returns this map with Structured Item values converted to BigDecimal objects. This map must contain StructuredDecimal or StructuredInteger values only.
      Returns:
      Map with values converted to BigDecimal
      Throws:
      UnsupportedOperationException - Thrown if this map contains a value which is neither StructuredDecimal nor StructuredInteger
    • doubleMap

      default Map<String,Double> doubleMap()
      Returns this map with Structured Item values converted to Double objects. This map must contain StructuredDecimal or StructuredInteger values only.
      Returns:
      Map with values converted to Double
      Throws:
      UnsupportedOperationException - Thrown if this map contains a value which is neither StructuredDecimal nor StructuredInteger
    • bytesMap

      default Map<String,byte[]> bytesMap()
      Returns this map with Structured Item values converted to byte[] objects. This map must contain StructuredBytes values only.
      Returns:
      Map with values converted to byte[]
      Throws:
      UnsupportedOperationException - Thrown if this map contains non-StructuredBytes values
    • getItem

      default <T extends StructuredItem> Optional<T> getItem(String key)
      Returns StructuredItem stored at requested key. No type check is performed.
      Type Parameters:
      T - Specific Item class if needed. No type check is performed, only simple casting.
      Parameters:
      key - Dictionary or Parameter key
      Returns:
      Structured Item at requested key, or empty Optional if there is no value at requested key
    • getItem

      default <T extends StructuredItem> Optional<T> getItem(String key, Class<T> itemClass)
      Returns StructuredItem stored at requested key. Throws an exception in case of a type mismatch.
      Type Parameters:
      T - Type of map value
      Parameters:
      key - Dictionary or Parameter key
      itemClass - Class of map value
      Returns:
      Structured Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When requested value is not an instance of requested itemClass
    • getString

      default Optional<String> getString(String key)
      Returns value of Item stored at requested key, converted to a String. Valid for all Item types: their String representation is returned.

      Mostly, it should be used for String and Token Items.

      Parameters:
      key - Dictionary or Parameter key
      Returns:
      String value of the Item at requested key, or empty Optional if there is no value at requested key
    • getBool

      default Optional<Boolean> getBool(String key)
      Returns Boolean value of the Item stored at requested key. Valid for StructuredBoolean Items only.
      Parameters:
      key - Dictionary or Parameter key
      Returns:
      Boolean value of the Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When Item at requested key is not a StructuredBoolean
    • getInt

      default Optional<Integer> getInt(String key)
      Returns Integer value of the Item stored at requested key. Valid for StructuredInteger Items only.

      (int) cast is used internally, which means that returned value will be wrong for item values smaller than Integer.MIN_VALUE or grater than Integer.MAX_VALUE.

      Parameters:
      key - Dictionary or Parameter key
      Returns:
      Integer value of the Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When Item at requested key is not a StructuredInteger
    • getLong

      default Optional<Long> getLong(String key)
      Returns Long value of the Item stored at requested key. Valid for StructuredInteger Items only.
      Parameters:
      key - Dictionary or Parameter key
      Returns:
      Long value of the Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When Item at requested key is not a StructuredInteger
    • getBigDecimal

      default Optional<BigDecimal> getBigDecimal(String key)
      Returns BigDecimal value of the Item stored at requested key. Valid for StructuredDecimal and StructuredInteger Items only.
      Parameters:
      key - Dictionary or Parameter key
      Returns:
      BigDecimal value of the Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When Item at requested key is neither StructuredDecimal nor StructuredInteger
    • getDouble

      default Optional<Double> getDouble(String key)
      Returns Double value of the Item stored at requested key. Valid for StructuredDecimal and StructuredInteger Items only.
      Parameters:
      key - Dictionary or Parameter key
      Returns:
      Double value of the Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When Item at requested key is neither StructuredDecimal nor StructuredInteger
    • getBytes

      default Optional<byte[]> getBytes(String key)
      Returns byte[] value of the Item stored at requested key. Valid for StructuredBytes Items only.
      Parameters:
      key - Dictionary or Parameter key
      Returns:
      byte[] value of the Item at requested key, or empty Optional if there is no value at requested key
      Throws:
      UnsupportedOperationException - When Item at requested key is not a StructuredBytes