Class EqualityAtmComparer

  • All Implemented Interfaces:
    AtmComboVisitor<java.lang.Boolean,​java.lang.Void>

    public class EqualityAtmComparer
    extends EquivalentAtmComboScanner<java.lang.Boolean,​java.lang.Void>
    Compares two annotated type mirrors for structural equality using only the primary annotations and underlying types of the two input types and their component types. Note, this leaves out other fields specific to some AnnotatedTypeMirrors (like directSupertypes, isUnderlyingTypeRaw, isUninferredTypeArgument etc...). Ideally, both EqualityAtmComparer and HashcodeAtmVisitor would visit relevant fields.

    This class is used by AnnotatedTypeMirror#equals

    This class should be kept synchronized with HashcodeAtmVisitor.

    See Also:
    Unlike HashcodeAtmVisitor this class is intended to be overridden.
    • Constructor Detail

      • EqualityAtmComparer

        public EqualityAtmComparer()
    • Method Detail

      • arePrimeAnnosEqual

        protected boolean arePrimeAnnosEqual​(AnnotatedTypeMirror type1,
                                             AnnotatedTypeMirror type2)
        Return true if type1 and type2 have equivalent sets of annotations.
        Parameters:
        type1 - a type
        type2 - a type
        Returns:
        true if type1 and type2 have equivalent sets of annotations
      • compare

        @EqualsMethod
        protected boolean compare​(AnnotatedTypeMirror type1,
                                  AnnotatedTypeMirror type2)
        Return true if the twe types are the same.
        Parameters:
        type1 - the first type to compare
        type2 - the second type to compare
        Returns:
        true if the twe types are the same
      • scanWithNull

        protected java.lang.Boolean scanWithNull​(AnnotatedTypeMirror type1,
                                                 AnnotatedTypeMirror type2,
                                                 java.lang.Void aVoid)
        Description copied from class: EquivalentAtmComboScanner
        In an AnnotatedTypeScanner a null type is encounter than null is returned. A user may want to customize the behavior of this scanner depending on whether or not one or both types is null.
        Specified by:
        scanWithNull in class EquivalentAtmComboScanner<java.lang.Boolean,​java.lang.Void>
        Parameters:
        type1 - a nullable AnnotatedTypeMirror
        type2 - a nullable AnnotatedTypeMirror
        aVoid - the visitor param
        Returns:
        a subclass specific return type/value
      • reduce

        protected java.lang.Boolean reduce​(java.lang.Boolean r1,
                                           java.lang.Boolean r2)
        Used to combine the results from component types or a type and its component types.
        Overrides:
        reduce in class EquivalentAtmComboScanner<java.lang.Boolean,​java.lang.Void>