Class ComparisonFlags


  • public class ComparisonFlags
    extends Object
    An object representing consolidated results of comparison of an hierarchical object.
    • Field Detail

      • NO_FLAGS

        public static final ComparisonFlags NO_FLAGS
        A flag tuple with all flags false.
    • Constructor Detail

      • ComparisonFlags

        public ComparisonFlags()
        The constructor.
    • Method Detail

      • setHasChanged

        public void setHasChanged​(ComparisonSide side1,
                                  ComparisonSide side2)
        Sets the "Has changed properties" flag for the specified direction.
        Parameters:
        side1 - the first side of the direction, not null
        side2 - the second side of the direction, not null
        value - the flag value to set
      • setHasOrderChanged

        public void setHasOrderChanged​(ComparisonSide side1,
                                       ComparisonSide side2)
        Sets the "Has changed order" flag for the specified direction.
        Parameters:
        side1 - the first side of the direction, not null
        side2 - the second side of the direction, not null
        value - the flag value to set
      • hasChangedMainOther

        public boolean hasChangedMainOther()
        Returns the flag "Main<->Other has changed"
        Returns:
        the flag "Main<->Other has changed"
      • hasDiffsMainOther

        public boolean hasDiffsMainOther()
        Checks whether there are differences between the main and other sides, that is, there are changed or partial objects.
        Returns:
        true if there are differences between the main and other sides.
      • hasChanged

        public boolean hasChanged​(ComparisonSide side1,
                                  ComparisonSide side2)
        Checks if the objects compared in the specified direction have changed properties (that is, properties with different values).
        Parameters:
        side1 - the first side of the direction, not null
        side2 - the second side of the direction, not null
        Returns:
        true if at least one property in the specified direction has different values
      • hasOrderChanged

        public boolean hasOrderChanged​(ComparisonSide side1,
                                       ComparisonSide side2)
        Checks whether the matched object with these flags has changed its order in its parent collection in the specified direction.
        Parameters:
        side1 - the first side of the direction, not null
        side2 - the second side of the direction, not null
        Returns:
        true if the object's order was changed
      • setHasUnchanged

        public void setHasUnchanged​(ComparisonSide side1,
                                    ComparisonSide side2)
        Sets the "Has unchanged properties" flag for the specified direction.
        Parameters:
        side1 - the first side of the direction, not null
        side2 - the second side of the direction, not null
      • hasUnchanged

        public boolean hasUnchanged​(ComparisonSide side1,
                                    ComparisonSide side2)
        Checks if the objects compared in the specified direction have unchanged properties (that is, properties with equal values).
        Parameters:
        side1 - the first side of the direction, not null
        side2 - the second side of the direction, not null
        Returns:
        true if at least one property in the specified direction has equal values
      • merge

        public void merge​(ComparisonFlags other)
        Merges flags from the specified comparison flags object. This does not include order flags. Call this method to combine flags of child comparison nodes into the parent one.
        Parameters:
        other - the comparison object to merge its flags from, not null
      • addFlags

        public void addFlags​(ComparisonFlags flags)
        Adds the specified comparison flags.
        Parameters:
        flags - the flags to be added, not null
      • clear

        public void clear()
        Clears all flags.
      • setHasDoubleChanges

        public void setHasDoubleChanges()
        Sets the "Has double changes" flag value
        Parameters:
        value - the value to set
      • hasDoubleChanges

        public boolean hasDoubleChanges()
        Tells whether the flags contain conflict changes between MAIN and OTHER relative the COMMON_ANCESTOR. This flag is applicable only for three-way comparison case.
        Returns:
        true if have conflict changes between MAIN and OTHER, false otherwise
      • hasNonDoubleChanges

        public boolean hasNonDoubleChanges()
        Tells whether the flags contain non-conflict changes between MAIN and OTHER. This flag is applicable only for three-way comparison case.
        Returns:
        true if have non-conflict changes between MAIN and OTHER, false otherwise
      • isOnOneSide

        public boolean isOnOneSide​(ComparisonSide presentSide,
                                   ComparisonSide absentSide)
        Checks whether there are compared objects present on the specified side and absent at the other specified side.
        Parameters:
        presentSide - the "present" side of direction
        absentSide - the "absent" side of direction
        Returns:
        true if the flags represent a compared object containing at least one compared subobject present on presentSide and absent on absentSide
      • setOnOneSide

        public void setOnOneSide​(ComparisonSide presentSide,
                                 ComparisonSide absentSide)
        Sets the "on one side" flag for the specified direction.
        Parameters:
        presentSide - the side on which a partial object is present
        absentSide - the side on which a partial object is absent
      • hasDifferences

        public boolean hasDifferences​(ComparisonSide side1,
                                      ComparisonSide side2)
        Checks whether there are differences between two specified sides, that is, there are changed or partial objects between them.
        Parameters:
        side1 - the first side
        side2 - the second side
        Returns:
        true if there are differences between the sides
      • toBase64

        public String toBase64()
        Returns a base64 representation of the object. Must be synchronized with #fromBase64(long) method.
        Returns:
        the base64 representation of the object.
      • toString

        public String toString()
        Must be synchronized with #fromString(String) method.
        Overrides:
        toString in class Object