Package org.nuxeo.ecm.core.storage
Class StateHelper
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.StateHelper
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SerializabledeepCopy(Object value)Makes a deep copy of a value.static SerializabledeepCopy(Object value, boolean threadSafe)Makes a deep copy of a value, optionally thread-safe.static List<Serializable>deepCopy(List<Serializable> list)Makes a deep copy of aList.static List<Serializable>deepCopy(List<Serializable> list, boolean threadSafe)Makes a deep copy of aList, optionally thread-safe.static StatedeepCopy(State state)Makes a deep copy of aStatemap.static StatedeepCopy(State state, boolean threadSafe)Makes a deep copy of aStatemap, optionally thread-safe.static Serializablediff(Object[] a, Object[] b)static Serializablediff(Object a, Object b)Does a diff of two values.static Serializablediff(List<Object> a, List<Object> b)static State.StateDiffdiff(State a, State b)Makes a diff copy of twoStatemaps.static booleanequalsLoose(Object[] a, Object[] b)Compares two arrays of scalars.static booleanequalsLoose(Object a, Object b)Compares two values.static booleanequalsLoose(List<Serializable> a, List<Serializable> b)Compares twoLists.static booleanequalsLoose(State a, State b)Compares twoStates.static booleanequalsStrict(Object[] a, Object[] b)Compares two arrays of scalars.static booleanequalsStrict(Object a, Object b)Compares two values.static booleanequalsStrict(List<Serializable> a, List<Serializable> b)Compares twoLists.static booleanequalsStrict(State a, State b)Compares twoStates.static List<Object>findPull(List<Object> a, List<Object> b)static booleanisScalar(Object value)Checks if we have a base type compatible withStatehelper processing.static voidresetDeltas(State state)Changes the deltas stored into actual full values.static SerializablerpushOrValue(Serializable value)Returns a pure rpush ListDiff for the value if it's an array/list.
-
-
-
Method Detail
-
isScalar
public static boolean isScalar(Object value)
Checks if we have a base type compatible withStatehelper processing.
-
equalsStrict
public static boolean equalsStrict(Object[] a, Object[] b)
Compares two arrays of scalars.
-
equalsStrict
public static boolean equalsStrict(List<Serializable> a, List<Serializable> b)
Compares twoLists.
-
equalsLoose
public static boolean equalsLoose(Object[] a, Object[] b)
Compares two arrays of scalars.nullvalues are equivalent to empty arrays.
-
equalsLoose
public static boolean equalsLoose(List<Serializable> a, List<Serializable> b)
Compares twoLists.nullvalues are equivalent to empty lists.
-
deepCopy
public static Serializable deepCopy(Object value)
Makes a deep copy of a value.
-
deepCopy
public static Serializable deepCopy(Object value, boolean threadSafe)
Makes a deep copy of a value, optionally thread-safe.- Parameters:
threadSafe- iftrue, then thread-safe datastructures are used
-
deepCopy
public static State deepCopy(State state, boolean threadSafe)
Makes a deep copy of aStatemap, optionally thread-safe.- Parameters:
threadSafe- iftrue, then thread-safe datastructures are used
-
deepCopy
public static List<Serializable> deepCopy(List<Serializable> list)
Makes a deep copy of aList.
-
deepCopy
public static List<Serializable> deepCopy(List<Serializable> list, boolean threadSafe)
Makes a deep copy of aList, optionally thread-safe.- Parameters:
threadSafe- iftrue, then thread-safe datastructures are used
-
diff
public static Serializable diff(Object a, Object b)
Does a diff of two values.- Returns:
- a
State.StateDiff, aState.ListDiff,State.NOP, or an actual value (includingnull)
-
diff
public static Serializable diff(Object[] a, Object[] b)
-
diff
public static Serializable diff(List<Object> a, List<Object> b)
-
diff
public static State.StateDiff diff(State a, State b)
Makes a diff copy of twoStatemaps.The returned diff state contains only the key/values that changed.
nullvalues are equivalent to absent values.For values set to null or removed, the value is null.
When setting a delta, the old value is checked to know if the delta should be kept or if a full value should be set instead.
For sub-documents, a recursive diff is returned.
- Returns:
- a
State.StateDiffwhich, when applied to a, gives b.
-
rpushOrValue
public static Serializable rpushOrValue(Serializable value)
Returns a pure rpush ListDiff for the value if it's an array/list.- Parameters:
value- the value- Returns:
- a pure rpush ListDiff for the value, if possible
- Since:
- 11.4
-
resetDeltas
public static void resetDeltas(State state)
Changes the deltas stored into actual full values.- Since:
- 6.0
-
-