Class EquivalenceKey

java.lang.Object
org.jboss.jandex.EquivalenceKey
Direct Known Subclasses:
EquivalenceKey.DeclarationEquivalenceKey, EquivalenceKey.TypeEquivalenceKey

public abstract class EquivalenceKey extends 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
  • Method Details

    • of

      public static EquivalenceKey of(AnnotationTarget annotationTarget)
      Returns an equivalence key for given annotation target.
      Parameters:
      annotationTarget - the annotation target, may be null
      Returns:
      equvalence key for given annotation target, only null if annotationTarget == null
    • of

      public static EquivalenceKey.DeclarationEquivalenceKey of(Declaration declaration)
      Returns an equivalence key for given declaration.
      Parameters:
      declaration - the declaration, may be null
      Returns:
      equvalence key for given declaration, only null if declaration == null
      Since:
      3.1.0
    • of

      Returns an equivalence key for given class.
      Parameters:
      clazz - the class, may be null
      Returns:
      equvalence key for given class, only null if clazz == null
    • of

      Returns an equivalence key for given method.
      Parameters:
      method - the method, may be null
      Returns:
      equvalence key for given method, only null if method == null
    • of

      Returns an equivalence key for given method parameter.
      Parameters:
      parameter - the method parameter, may be null
      Returns:
      equvalence key for given method parameter, only null if parameter == null
    • of

      Returns an equivalence key for given field.
      Parameters:
      field - the field, may be null
      Returns:
      equvalence key for given field, only null if field == null
    • of

      Returns an equivalence key for given record component.
      Parameters:
      recordComponent - the record component, may be null
      Returns:
      equvalence key for given record component, only null if recordComponent == null
    • of

      public static EquivalenceKey.TypeEquivalenceKey of(TypeTarget typeTarget)
      Returns an equivalence key for given type annotation target. It is the equivalence key of the annotated type.
      Parameters:
      typeTarget - the type target, may be null
      Returns:
      equvalence key for given type target, only null if typeTarget == null
    • of

      public static EquivalenceKey.TypeEquivalenceKey of(Type type)
      Returns an equivalence key for given type.
      Parameters:
      type - the type, may be null
      Returns:
      equvalence key for given type, only null if type == null