Class EquivalenceKey

  • Direct Known Subclasses:
    EquivalenceKey.DeclarationEquivalenceKey, EquivalenceKey.TypeEquivalenceKey

    public abstract class EquivalenceKey
    extends java.lang.Object
    Establishes a notion of equivalence of Jandex objects. Two Jandex objects are equivalent if and only if they denote the same Java declaration or type, without taking into account any annotations. The prime use case is to assist with building annotation overlays on top of Jandex, where it is common to have multiple Jandex objects with different annotations, but otherwise equivalent.

    In contrast, the common Jandex classes such as ClassInfo, MethodInfo or FieldInfo either don't provide equality at all (and hence can only be compared by identity) or provide strict equality, which includes presence or absence of annotations and comparison of their members, as well as other details.

    An instance of this class, also called an equivalence key, provides 3 fundamental operations, corresponding to the 3 common methods all Java classes have:

    • equals(): when two Jandex objects are equivalent, their equivalence keys are equal
    • hashCode(): consistent with equals() described above
    • toString(): human readable representation of the equivalence key; format of the value is not guaranteed and may change without notice
    In addition, equivalence keys are structured in an inheritance hierarchy that corresponds to the inheritance hierarchy of Jandex objects. Therefore, the kind of the "source" Jandex object may be found by inspecting the class of the equivalence key:
    • EquivalenceKey
      • DeclarationEquivalenceKey
        • ClassEquivalenceKey
        • MethodEquivalenceKey
        • MethodParameterEquivalenceKey
        • FieldEquivalenceKey
        • RecordComponentEquivalenceKey
      • TypeEquivalenceKey
        • ArrayTypeEquivalenceKey
        • ClassTypeEquivalenceKey
        • ParameterizedTypeEquivalenceKey
        • PrimitiveTypeEquivalenceKey
        • TypeVariableEquivalenceKey
        • TypeVariableReferenceEquivalenceKey
        • UnresolvedTypeVariableEquivalenceKey
        • VoidTypeEquivalenceKey
        • WildcardTypeEquivalenceKey