Class GsonUtils
java.lang.Object
org.hibernate.search.backend.elasticsearch.gson.impl.GsonUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TEfficiently performs a deep copy of a given object using Gson serialization/deserialization.static voidsetOrAppendToArray(com.google.gson.JsonObject object, String propertyName, com.google.gson.JsonElement newValue) Sets the givennewValueas the value of propertypropertyNameonparent, wrapping it in an array if necessary.
-
Method Details
-
setOrAppendToArray
public static void setOrAppendToArray(com.google.gson.JsonObject object, String propertyName, com.google.gson.JsonElement newValue) Sets the givennewValueas the value of propertypropertyNameonparent, wrapping it in an array if necessary.The behavior is as follows:
- If there is currently no value for this property, the property is simply set to
newValueusingJsonObject.add(String, JsonElement). - If the current value of the property is an array,
newValueis added to this array. - Otherwise, the current value
is replaced by an array containing the current value followed by the
newValue.
- Parameters:
object- The object whose property must be set.propertyName- The name of the property to set.newValue- The value to set.
- If there is currently no value for this property, the property is simply set to
-
deepCopy
Efficiently performs a deep copy of a given object using Gson serialization/deserialization.- Type Parameters:
T- The type of the object to copy.- Parameters:
gson- TheGsonobject.objectType- The type of the object to copy.object- The object to copy.- Returns:
- A deep copy of
object.
-