Package co.arago.hiro.client.model
Class HiroJsonMap
- java.lang.Object
-
- co.arago.hiro.client.model.HiroJsonMap
-
- All Implemented Interfaces:
JsonMessage,ToMap,java.io.Serializable
- Direct Known Subclasses:
AbstractActionHandlerIdMessage,ActionHandlerError,DecodedToken,DecodedToken.Data,EventsMessage,HiroError,HiroError.HiroErrorEntry,HiroMessage,MetaValueList.MetaValueField,VersionResponse.VersionEntry
public class HiroJsonMap extends java.lang.Object implements JsonMessage, ToMap
This is a generic model class that collects all keys and values of a JSON object infieldsMap. The keys need to be strings. Derived children will specify specific fields for JSON data, while all remaining data will be collected in this map.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>fieldsMapAll unknown keys - if any - of the JSON will be collected here
-
Constructor Summary
Constructors Constructor Description HiroJsonMap()Default constructor for JacksonHiroJsonMap(java.util.Map<java.lang.String,java.lang.Object> initialData)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFields(java.util.Map<java.lang.String,java.lang.Object> data)java.lang.ObjectgetField(java.lang.String key)Returns any field found in this class, being insidefieldsMapor a field of a derived class.java.util.Map<java.lang.String,?>getMap()Returns the map of fields that have NOT been assigned to fields of derived children directly.java.lang.ObjectgetUnmappedField(java.lang.String key)Returns a value from thefieldsMap, which are fields that have NOT been assigned to fields of derived children directly.voidsetField(java.lang.String key, java.lang.Object value)Set a single field infieldsMap.voidsetFields(java.util.Map<java.lang.String,java.lang.Object> data)java.util.Map<java.lang.String,java.lang.Object>toMap()Return a map of ALL values, including assigned fields specified in derived child classes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface co.arago.hiro.client.model.JsonMessage
toJsonString, toJsonStringNoNull, toPrettyJsonString, toPrettyJsonStringNoNull
-
-
-
-
Constructor Detail
-
HiroJsonMap
public HiroJsonMap()
Default constructor for Jackson
-
HiroJsonMap
public HiroJsonMap(java.util.Map<java.lang.String,java.lang.Object> initialData)
Constructor- Parameters:
initialData- Initial data for the fieldsMap. Data will be copied viaMap.putAll(Map)intofieldsMap.
-
-
Method Detail
-
setField
public void setField(java.lang.String key, java.lang.Object value)Set a single field infieldsMap. This is also the generic method for Jackson to set fields.- Parameters:
key- Key of the field.value- Value of the field.
-
setFields
public void setFields(java.util.Map<java.lang.String,java.lang.Object> data)
- Parameters:
data-fieldsMapwill be cleared and data will be copied viaMap.putAll(Map)into it.
-
addFields
public void addFields(java.util.Map<java.lang.String,java.lang.Object> data)
- Parameters:
data- Data will be copied viaMap.putAll(Map)intofieldsMap.
-
getUnmappedField
public java.lang.Object getUnmappedField(java.lang.String key)
Returns a value from thefieldsMap, which are fields that have NOT been assigned to fields of derived children directly.
-
getField
public java.lang.Object getField(java.lang.String key)
Returns any field found in this class, being insidefieldsMapor a field of a derived class.(This is a costly operation to be called multiple times on the same object. It might be more efficient to use
toMap()and get the fields from the map returned.)- Parameters:
key- The name of the field.- Returns:
- The value found.
-
getMap
public java.util.Map<java.lang.String,?> getMap()
Returns the map of fields that have NOT been assigned to fields of derived children directly.- Returns:
- The map of the remaining fields.
-
-