Class UnknownAware


  • public abstract class UnknownAware
    extends Object
    This base class allows to keep unknown json properties.
    Author:
    Christian Bremer
    • Constructor Detail

      • UnknownAware

        public UnknownAware()
    • Method Detail

      • unknown

        public Map<String,​Object> unknown()
        Gets the unknown json properties (can be null).
        Returns:
        the unknown
      • unknown

        public void unknown​(Map<String,​Object> unknown)
        Sets the unknown json properties.
        Parameters:
        unknown - the unknown json properties
      • unknown

        public void unknown​(String name,
                            Object value)
        Any json setter.
        Parameters:
        name - the name
        value - the value
      • hasUnknown

        public boolean hasUnknown()
        Returns true if there are unknown properties, otherwise false.
        Returns:
        true if there are unknown properties, otherwise false
      • findUnknown

        public <T> Optional<T> findUnknown​(String jsonPath,
                                           Class<T> clazz)
        Find a value from the unknown map.
        Type Parameters:
        T - the class type
        Parameters:
        jsonPath - the json path, e. g. $.firstKey.secondKey.thirdKey
        clazz - the expected result class
        Returns:
        an empty optional if the value was not found or can not be casted, otherwise the value
      • findUnknownList

        public <E> Optional<List<E>> findUnknownList​(String jsonPath,
                                                     Class<E> clazz)
        Find a list from the unknown map.
        Type Parameters:
        E - the list element type
        Parameters:
        jsonPath - the json path, e. g. $.firstKey.secondKey.thirdKey
        clazz - he list element type
        Returns:
        an empty optional if the list was not found or can not be casted, otherwise the list
      • findUnknownMap

        public Optional<Map<String,​Object>> findUnknownMap​(String jsonPath)
        Find a map / json object from the unknown map.
        Parameters:
        jsonPath - the json path, e. g. $.firstKey.secondKey.thirdKey
        Returns:
        an empty optional if the map / json object was not found or can not be casted, otherwise the map / json object