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 Serializable
deepCopy(Object value)
Makes a deep copy of a value.static Serializable
deepCopy(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 State
deepCopy(State state)
Makes a deep copy of aState
map.static State
deepCopy(State state, boolean threadSafe)
Makes a deep copy of aState
map, optionally thread-safe.static Serializable
diff(Object[] a, Object[] b)
static Serializable
diff(Object a, Object b)
Does a diff of two values.static Serializable
diff(List<Object> a, List<Object> b)
static State.StateDiff
diff(State a, State b)
Makes a diff copy of twoState
maps.static boolean
equalsLoose(Object[] a, Object[] b)
Compares two arrays of scalars.static boolean
equalsLoose(Object a, Object b)
Compares two values.static boolean
equalsLoose(List<Serializable> a, List<Serializable> b)
Compares twoList
s.static boolean
equalsLoose(State a, State b)
Compares twoState
s.static boolean
equalsStrict(Object[] a, Object[] b)
Compares two arrays of scalars.static boolean
equalsStrict(Object a, Object b)
Compares two values.static boolean
equalsStrict(List<Serializable> a, List<Serializable> b)
Compares twoList
s.static boolean
equalsStrict(State a, State b)
Compares twoState
s.static List<Object>
findPull(List<Object> a, List<Object> b)
static boolean
isScalar(Object value)
Checks if we have a base type compatible withState
helper processing.static void
resetDeltas(State state)
Changes the deltas stored into actual full values.static Serializable
rpushOrValue(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 withState
helper 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 twoList
s.
-
equalsLoose
public static boolean equalsLoose(Object[] a, Object[] b)
Compares two arrays of scalars.null
values are equivalent to empty arrays.
-
equalsLoose
public static boolean equalsLoose(List<Serializable> a, List<Serializable> b)
Compares twoList
s.null
values 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 aState
map, 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 twoState
maps.The returned diff state contains only the key/values that changed.
null
values 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.StateDiff
which, 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
-
-