Enum DifferenceType

java.lang.Object
java.lang.Enum<DifferenceType>
de.serra.so_dirty.difference.DifferenceType
All Implemented Interfaces:
Serializable, Comparable<DifferenceType>

public enum DifferenceType extends Enum<DifferenceType>
The kind of difference.

What this means is different depending on what is being compared. In this Table then and now is used to describe the object in the past and present:

The meaning of DifferenceType
SnapshotNode type REFERENCE EQUALITY TYPE_CHANGE KEY_ADDED KEY_REMOVED
Any different sub classes of SnapshotNode Always Always Always
ReferenceSnapshotNode
!then.equals(now)
!then.equals(now)
!then.getClass().equals(now.getClass())
never never
ArraySnapshotNode
then != now
!then.equals(now)
!then.getClass().getComponentType().equals(now.getClass().getComponentType())
never never
ClassSnapshotNode
!then != now
!then.equals(now)
!then.getClass().equals(now.getClass())
never never
MapSnapshotNode
!then != now
!then.equals(now)
!then.getClass().equals(now.getClass())
for (var nowKey : now.keySet()) {
	if (!then.containsKey(nowKey)) {
		return true;
	}
}
return false;
for (var thenKey : then.keySet()) {
	if (!now.containsKey(thenKey)) {
		return true;
	}
}
return false;
In addition to the table there are some special cases:

null diffed against a non null value is always all three difference types. null diffed against null is always none of the difference types.

Author:
Peter Lamby
  • Enum Constant Details

    • REFERENCE

      public static final DifferenceType REFERENCE
      The value is different by reference (==).
    • EQUALITY

      public static final DifferenceType EQUALITY
      The value is different by equality (Object.equals(Object).
    • TYPE_CHANGE

      public static final DifferenceType TYPE_CHANGE
      The class of the value changed. This always implies REFERENCE.
    • KEY_ADDED

      public static final DifferenceType KEY_ADDED
      A key was found in a Map that was not there in the previous snapshot.

      The keys are compared by equality.

    • KEY_REMOVED

      public static final DifferenceType KEY_REMOVED
      A key that was previously in a Map is not there anymore.

      The keys are compared by equality.

  • Method Details

    • values

      public static DifferenceType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static DifferenceType valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null