Class ChangeInfoDiffer


  • public final class ChangeInfoDiffer
    extends Object
    Gets the differences between two ChangeInfos.

    This must be in package com.google.gerrit.extensions.common for access to protected constructors.

    This assumes that every class reachable from ChangeInfo has a non-private constructor with zero parameters and overrides the equals method.

    • Method Detail

      • getDifference

        public static ChangeInfoDifference getDifference​(ChangeInfo oldChangeInfo,
                                                         ChangeInfo newChangeInfo)
        Returns the difference between two instances of ChangeInfo.

        The ChangeInfoDifference returned has the following properties:

        Unrepeated fields are present in the difference returned when they differ between oldChangeInfo and newChangeInfo. When there's an unrepeated field that's not a String, primitive, or enum, its fields are only returned when they differ.

        Entries in Map fields are returned when a key is present in newChangeInfo and not oldChangeInfo. If a key is present in both, the diff of the value is returned.

        Collection fields in ChangeInfoDifference.added() contain only items found in newChangeInfo and not oldChangeInfo.

        Collection fields in ChangeInfoDifference.removed() contain only items found in oldChangeInfo and not newChangeInfo.

        Parameters:
        oldChangeInfo - the previous ChangeInfo to diff against newChangeInfo
        newChangeInfo - the ChangeInfo to diff against oldChangeInfo
        Returns:
        the difference between the given ChangeInfos