Skip to content

Commit

Permalink
move AnnotationInstance.RETENTION and Index.REPEATABLE to DotName
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed May 14, 2024
1 parent ddba5d4 commit afe4f49
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
5 changes: 2 additions & 3 deletions core/src/main/java/org/jboss/jandex/AnnotationInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
public final class AnnotationInstance {
static final NameComparator NAME_COMPARATOR = new NameComparator();
static final AnnotationInstance[] EMPTY_ARRAY = new AnnotationInstance[0];
static final DotName RETENTION = new DotName(DotName.JAVA_LANG_ANNOTATION_NAME, "Retention", true, false);

private final DotName name;
private final AnnotationTarget target;
Expand Down Expand Up @@ -97,8 +96,8 @@ public static AnnotationInstanceBuilder builder(ClassInfo annotationType) {
throw new IllegalArgumentException("Annotation type can't be null");
}
DotName name = annotationType.name();
boolean visible = annotationType.hasDeclaredAnnotation(RETENTION)
&& annotationType.declaredAnnotation(RETENTION).value().asString().equals("RUNTIME");
boolean visible = annotationType.hasDeclaredAnnotation(DotName.RETENTION_NAME)
&& annotationType.declaredAnnotation(DotName.RETENTION_NAME).value().asString().equals("RUNTIME");
return new AnnotationInstanceBuilder(name, visible);
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jboss/jandex/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public final List<AnnotationInstance> annotationsWithRepeatable(DotName name, In
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
for (AnnotationInstance container : annotations(containingType.name())) {
Expand Down Expand Up @@ -598,7 +598,7 @@ public final List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
AnnotationInstance container = declaredAnnotation(containingType.name());
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/jboss/jandex/DotName.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public final class DotName implements Comparable<DotName> {
public static final DotName ENUM_NAME;
public static final DotName RECORD_NAME;
public static final DotName STRING_NAME;
public static final DotName REPEATABLE_NAME;
public static final DotName RETENTION_NAME;

private final DotName prefix;
private final String local;
Expand All @@ -64,6 +66,8 @@ public final class DotName implements Comparable<DotName> {
ENUM_NAME = new DotName(JAVA_LANG_NAME, "Enum", true, false);
RECORD_NAME = new DotName(JAVA_LANG_NAME, "Record", true, false);
STRING_NAME = new DotName(JAVA_LANG_NAME, "String", true, false);
REPEATABLE_NAME = new DotName(JAVA_LANG_ANNOTATION_NAME, "Repeatable", true, false);
RETENTION_NAME = new DotName(DotName.JAVA_LANG_ANNOTATION_NAME, "Retention", true, false);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jboss/jandex/FieldInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public final List<AnnotationInstance> annotationsWithRepeatable(DotName name, In
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
for (AnnotationInstance container : annotations(containingType.name())) {
Expand Down Expand Up @@ -302,7 +302,7 @@ public final List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
AnnotationInstance container = declaredAnnotation(containingType.name());
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/org/jboss/jandex/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public final class Index implements IndexView {
private static final List<AnnotationInstance> EMPTY_ANNOTATION_LIST = Collections.emptyList();
private static final List<ClassInfo> EMPTY_CLASSINFO_LIST = Collections.emptyList();

static final DotName REPEATABLE = DotName.createSimple("java.lang.annotation.Repeatable");

final Map<DotName, AnnotationInstance[]> annotations;
final Map<DotName, ClassInfo[]> subclasses;
final Map<DotName, ClassInfo[]> subinterfaces;
Expand Down Expand Up @@ -331,7 +329,7 @@ public Collection<AnnotationInstance> getAnnotationsWithRepeatable(DotName annot
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable == null) {
// Not a repeatable annotation
return getAnnotations(annotationName);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jboss/jandex/MethodInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public final List<AnnotationInstance> annotationsWithRepeatable(DotName name, In
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
for (AnnotationInstance container : annotations(containingType.name())) {
Expand Down Expand Up @@ -525,7 +525,7 @@ public List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName name,
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
AnnotationInstance container = declaredAnnotation(containingType.name());
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jboss/jandex/MethodParameterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public List<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexVie
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
for (AnnotationInstance container : annotations(containingType.name())) {
Expand Down Expand Up @@ -296,7 +296,7 @@ public List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName name,
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
AnnotationInstance container = declaredAnnotation(containingType.name());
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jboss/jandex/RecordComponentInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public final List<AnnotationInstance> annotationsWithRepeatable(DotName name, In
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
for (AnnotationInstance container : annotations(containingType.name())) {
Expand Down Expand Up @@ -285,7 +285,7 @@ public final List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
AnnotationInstance container = declaredAnnotation(containingType.name());
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jboss/jandex/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public final List<AnnotationInstance> annotationsWithRepeatable(DotName name, In
if (!annotationClass.isAnnotation()) {
throw new IllegalArgumentException("Not an annotation type: " + annotationClass);
}
AnnotationInstance repeatable = annotationClass.declaredAnnotation(Index.REPEATABLE);
AnnotationInstance repeatable = annotationClass.declaredAnnotation(DotName.REPEATABLE_NAME);
if (repeatable != null) {
Type containingType = repeatable.value().asClass();
AnnotationInstance container = annotation(containingType.name());
Expand Down

0 comments on commit afe4f49

Please sign in to comment.