Package org.jboss.jandex
Class EquivalenceKey
- java.lang.Object
-
- org.jboss.jandex.EquivalenceKey
-
- Direct Known Subclasses:
EquivalenceKey.DeclarationEquivalenceKey,EquivalenceKey.TypeEquivalenceKey
public abstract class EquivalenceKey extends java.lang.ObjectEstablishes 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,MethodInfoorFieldInfoeither 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 equalhashCode(): consistent withequals()described abovetoString(): human-readable representation of the equivalence key; format of the value is not guaranteed and may change without notice
EquivalenceKeyDeclarationEquivalenceKeyClassEquivalenceKeyFieldEquivalenceKeyMethodEquivalenceKeyMethodParameterEquivalenceKeyRecordComponentEquivalenceKey
TypeEquivalenceKeyArrayTypeEquivalenceKeyClassTypeEquivalenceKeyParameterizedTypeEquivalenceKeyPrimitiveTypeEquivalenceKeyTypeVariableEquivalenceKeyTypeVariableReferenceEquivalenceKeyUnresolvedTypeVariableEquivalenceKeyVoidTypeEquivalenceKeyWildcardTypeEquivalenceKey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEquivalenceKey.ArrayTypeEquivalenceKeystatic classEquivalenceKey.ClassEquivalenceKeystatic classEquivalenceKey.ClassTypeEquivalenceKeystatic classEquivalenceKey.DeclarationEquivalenceKeystatic classEquivalenceKey.FieldEquivalenceKeystatic classEquivalenceKey.MethodEquivalenceKeystatic classEquivalenceKey.MethodParameterEquivalenceKeystatic classEquivalenceKey.ParameterizedTypeEquivalenceKeystatic classEquivalenceKey.PrimitiveTypeEquivalenceKeystatic classEquivalenceKey.RecordComponentEquivalenceKeystatic classEquivalenceKey.TypeEquivalenceKeystatic classEquivalenceKey.TypeVariableEquivalenceKeystatic classEquivalenceKey.TypeVariableReferenceEquivalenceKeystatic classEquivalenceKey.UnresolvedTypeVariableEquivalenceKeystatic classEquivalenceKey.VoidTypeEquivalenceKeystatic classEquivalenceKey.WildcardTypeEquivalenceKey
-
Constructor Summary
Constructors Modifier Constructor Description privateEquivalenceKey()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EquivalenceKeyof(AnnotationTarget annotationTarget)Returns an equivalence key for given annotation target.static EquivalenceKey.ClassEquivalenceKeyof(ClassInfo clazz)Returns an equivalence key for given class.static EquivalenceKey.DeclarationEquivalenceKeyof(Declaration declaration)Returns an equivalence key for given declaration.static EquivalenceKey.FieldEquivalenceKeyof(FieldInfo field)Returns an equivalence key for given field.static EquivalenceKey.MethodEquivalenceKeyof(MethodInfo method)Returns an equivalence key for given method.static EquivalenceKey.MethodParameterEquivalenceKeyof(MethodParameterInfo parameter)Returns an equivalence key for given method parameter.static EquivalenceKey.RecordComponentEquivalenceKeyof(RecordComponentInfo recordComponent)Returns an equivalence key for given record component.static EquivalenceKey.TypeEquivalenceKeyof(Type type)Returns an equivalence key for given type.private static EquivalenceKey.TypeEquivalenceKey[]of(Type[] types)static EquivalenceKey.TypeEquivalenceKeyof(TypeTarget typeTarget)Returns an equivalence key for given type annotation target.private static booleanstartsWithJava(DotName name)private static java.lang.StringtoStringWhereClause(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)(package private) java.lang.StringtoStringWithWhere(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
-
-
-
Method Detail
-
of
public static EquivalenceKey of(AnnotationTarget annotationTarget)
Returns an equivalence key for given annotation target.- Parameters:
annotationTarget- the annotation target, may benull- Returns:
- equivalence key for given annotation target, only
nullifannotationTarget == null
-
of
public static EquivalenceKey.DeclarationEquivalenceKey of(Declaration declaration)
Returns an equivalence key for given declaration.- Parameters:
declaration- the declaration, may benull- Returns:
- equivalence key for given declaration, only
nullifdeclaration == null - Since:
- 3.1.0
-
of
public static EquivalenceKey.ClassEquivalenceKey of(ClassInfo clazz)
Returns an equivalence key for given class.- Parameters:
clazz- the class, may benull- Returns:
- equivalence key for given class, only
nullifclazz == null
-
of
public static EquivalenceKey.MethodEquivalenceKey of(MethodInfo method)
Returns an equivalence key for given method.- Parameters:
method- the method, may benull- Returns:
- equivalence key for given method, only
nullifmethod == null
-
of
public static EquivalenceKey.MethodParameterEquivalenceKey of(MethodParameterInfo parameter)
Returns an equivalence key for given method parameter.- Parameters:
parameter- the method parameter, may benull- Returns:
- equivalence key for given method parameter, only
nullifparameter == null
-
of
public static EquivalenceKey.FieldEquivalenceKey of(FieldInfo field)
Returns an equivalence key for given field.- Parameters:
field- the field, may benull- Returns:
- equivalence key for given field, only
nulliffield == null
-
of
public static EquivalenceKey.RecordComponentEquivalenceKey of(RecordComponentInfo recordComponent)
Returns an equivalence key for given record component.- Parameters:
recordComponent- the record component, may benull- Returns:
- equivalence key for given record component, only
nullifrecordComponent == 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 benull- Returns:
- equivalence key for given type target, only
nulliftypeTarget == null
-
of
public static EquivalenceKey.TypeEquivalenceKey of(Type type)
Returns an equivalence key for given type.- Parameters:
type- the type, may benull- Returns:
- equivalence key for given type, only
nulliftype == null
-
of
private static EquivalenceKey.TypeEquivalenceKey[] of(Type[] types)
-
toStringWithWhere
java.lang.String toStringWithWhere(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
-
toStringWhereClause
private static java.lang.String toStringWhereClause(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
-
startsWithJava
private static boolean startsWithJava(DotName name)
-
-