Package org.bremersee.common.model
Class UnknownAware
- java.lang.Object
-
- org.bremersee.common.model.UnknownAware
-
public abstract class UnknownAware extends Object
This base class allows to keep unknown json properties.- Author:
- Christian Bremer
-
-
Constructor Summary
Constructors Constructor Description UnknownAware()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Optional<T>findUnknown(String jsonPath, Class<T> clazz)Find a value from the unknown map.<E> Optional<List<E>>findUnknownList(String jsonPath, Class<E> clazz)Find a list from the unknown map.Optional<Map<String,Object>>findUnknownMap(String jsonPath)Find a map / json object from the unknown map.booleanhasUnknown()Returnstrueif there are unknown properties, otherwisefalse.Map<String,Object>unknown()Gets the unknown json properties (can benull).voidunknown(String name, Object value)Any json setter.voidunknown(Map<String,Object> unknown)Sets the unknown json properties.
-
-
-
Method Detail
-
unknown
public Map<String,Object> unknown()
Gets the unknown json properties (can benull).- 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 namevalue- the value
-
hasUnknown
public boolean hasUnknown()
Returnstrueif there are unknown properties, otherwisefalse.- Returns:
trueif there are unknown properties, otherwisefalse
-
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.thirdKeyclazz- 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.thirdKeyclazz- 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
-
-