Class ExtraJson.JsonMap
java.lang.Object
tenapull.data.entity.objectLookup.ExtraJson.JsonMap
- Enclosing class:
- ExtraJson
public static class ExtraJson.JsonMap
extends java.lang.Object
A wrapper for the map representing the key-value pairs of the ExtraJson. Hibernate is
not able to directly process a Map, but by wrapping it I am able to use a converter
to convert between the DB and the ORM
-
Constructor Summary
Constructors Constructor Description JsonMap()
Instantiates a new empty JsonMapJsonMap(java.lang.String jsonStr)
Instantiates a new Json map by deserializing the provided stringJsonMap(java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> map)
Instantiates a new JsonMap, copying the provided map -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
Hash
get_hash()
Calculates the hash of the JsonMap if it is not already calculated, or returns the pre-calculated hash if it was calculated.java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode>
getView()
Gets the immutable view of the mapint
hashCode()
java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode>
makeCopy()
Returns a mutable copy of the mapvoid
set_hash(Hash hash)
Sets the hash after performing an immutability checkjava.lang.String
toString()
Serializes the map into a string
-
Constructor Details
-
JsonMap
public JsonMap()Instantiates a new empty JsonMap -
JsonMap
public JsonMap(java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> map)Instantiates a new JsonMap, copying the provided map- Parameters:
map
- the map
-
JsonMap
public JsonMap(java.lang.String jsonStr) throws com.fasterxml.jackson.core.JsonProcessingException, java.lang.IllegalArgumentExceptionInstantiates a new Json map by deserializing the provided string- Parameters:
jsonStr
- the json string to deserialize- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there was an exception while deserializingjava.lang.IllegalArgumentException
- if the deserialized JsonNode is not an ObjectNode
-
-
Method Details
-
getView
public java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> getView()Gets the immutable view of the map- Returns:
- the view
-
makeCopy
public java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> makeCopy()Returns a mutable copy of the map- Returns:
- the map
-
toString
public java.lang.String toString()Serializes the map into a string- Overrides:
toString
in classjava.lang.Object
- Returns:
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
get_hash
Calculates the hash of the JsonMap if it is not already calculated, or returns the pre-calculated hash if it was calculated.- Returns:
- the SHA-512 hash of the serialized map
-
set_hash
Sets the hash after performing an immutability check- Parameters:
hash
- the hash to set- Throws:
java.lang.IllegalStateException
- if the hash is being changed to a value different than previously set. All values including the hash are intended to be immutable once a lookup record is created
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-