Class StateHelper

java.lang.Object
org.nuxeo.ecm.core.storage.StateHelper

public class StateHelper extends Object
Helpers for deep copy and deep diff of State objects.
  • Method Details

    • isScalar

      public static boolean isScalar(Object value)
      Checks if we have a base type compatible with State helper processing.
    • equalsStrict

      public static boolean equalsStrict(Object a, Object b)
      Compares two values.
    • equalsStrict

      public static boolean equalsStrict(State a, State b)
      Compares two States.
    • 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 two Lists.
    • equalsLoose

      public static boolean equalsLoose(Object a, Object b)
      Compares two values.

      A null value or an empty array or List is equivalent to an absent value. A null State is equivalent to an empty State (or a State containing only absent values).

    • equalsLoose

      public static boolean equalsLoose(State a, State b)
      Compares two States.

      A null value or an empty array or List is equivalent to an absent value. A null State is equivalent to an empty State (or a State containing only absent values).

    • 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 two Lists.

      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 - if true, then thread-safe datastructures are used
    • deepCopy

      public static State deepCopy(State state)
      Makes a deep copy of a State map.
    • deepCopy

      public static State deepCopy(State state, boolean threadSafe)
      Makes a deep copy of a State map, optionally thread-safe.
      Parameters:
      threadSafe - if true, then thread-safe datastructures are used
    • deepCopy

      public static List<Serializable> deepCopy(List<Serializable> list)
      Makes a deep copy of a List.
    • deepCopy

      public static List<Serializable> deepCopy(List<Serializable> list, boolean threadSafe)
      Makes a deep copy of a List, optionally thread-safe.
      Parameters:
      threadSafe - if true, 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, a State.ListDiff, State.NOP, or an actual value (including null)
    • diff

      public static Serializable diff(Object[] a, Object[] b)
    • diff

      public static Serializable diff(List<Object> a, List<Object> b)
    • findPull

      public static List<Object> findPull(List<Object> a, List<Object> b)
      Since:
      11.5
    • diff

      public static State.StateDiff diff(State a, State b)
      Makes a diff copy of two State 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