Skip to content

Commit

Permalink
remove AnnotationMember
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Jul 30, 2021
1 parent ed2963a commit e968b9a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.lang.annotation.Annotation;
import java.lang.annotation.Repeatable;
import java.util.Collection;
import java.util.Map;

/**
* An annotation instance, typically obtained from an {@link AnnotationTarget}.
Expand Down Expand Up @@ -82,10 +82,10 @@ default AnnotationMemberValue value() {
}

/**
* Returns all members of this annotation. Returns an empty collection
* if this annotation has no members.
* Returns all members of this annotation as a map, where the key is the member name
* and the value is the member value. Returns an empty map if this annotation has no members.
*
* @return an immutable collection of all members of this annotation, never {@code null}
* @return an immutable map of all members of this annotation, never {@code null}
*/
Collection<AnnotationMember> members();
Map<String, AnnotationMemberValue> members();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

/**
* The value of an {@link AnnotationMember}. Annotation member values are of several kinds:
* The value of an annotation member. Annotation member values are of several kinds:
* <ul>
* <li>primitive types;</li>
* <li>{@link String}s;</li>
Expand Down Expand Up @@ -34,35 +34,35 @@ public interface AnnotationMemberValue {
*/
enum Kind {
/**
* A primitive {@code boolean}.
* A primitive {@code boolean} value.
*/
BOOLEAN,
/**
* A primitive {@code byte}.
* A primitive {@code byte} value.
*/
BYTE,
/**
* A primitive {@code short}.
* A primitive {@code short} value.
*/
SHORT,
/**
* A primitive {@code int}.
* A primitive {@code int} value.
*/
INT,
/**
* A primitive {@code long}.
* A primitive {@code long} value.
*/
LONG,
/**
* A primitive {@code float}.
* A primitive {@code float} value.
*/
FLOAT,
/**
* A primitive {@code double}.
* A primitive {@code double} value.
*/
DOUBLE,
/**
* A primitive {@code char}.
* A primitive {@code char} value.
*/
CHAR,
/**
Expand All @@ -74,7 +74,7 @@ enum Kind {
*/
ENUM,
/**
* A {@link Class} value. Represented as {@link jakarta.enterprise.lang.model.types.Type}.
* A {@link Class} value. Represented as {@link Type}.
*/
CLASS,
/**
Expand All @@ -89,9 +89,9 @@ enum Kind {
}

/**
* Returns the kind of the annotation member value.
* Returns the kind of this annotation member value.
*
* @return the kind of the annotation member value, never {@code null}
* @return the kind of this annotation member value, never {@code null}
*/
Kind kind();

Expand Down Expand Up @@ -187,113 +187,112 @@ default boolean isArray() {
}

/**
* Returns the value as a boolean.
* Returns this value as a boolean.
*
* @return the boolean value
* @throws IllegalStateException if this annotation member value is not a boolean
*/
boolean asBoolean();

/**
* Returns the value as a byte.
* Returns this value as a byte.
*
* @return the byte value
* @throws IllegalStateException if the value cannot be represented as a byte
*/
byte asByte();

/**
* Returns the value as a short.
* Returns this value as a short.
*
* @return the short value
* @throws IllegalStateException if the value cannot be represented as a short.
*/
short asShort();

/**
* Returns the value as an int.
* Returns this value as an int.
*
* @return the int value
* @throws IllegalStateException if the value cannot be represented as an int.
*/
int asInt();

/**
* Returns the value as a long.
* Returns this value as a long.
*
* @return the long value
* @throws IllegalStateException if the value cannot be represented as a long.
*/
long asLong();

/**
* Returns the value as a float.
* Returns this value as a float.
*
* @return the float value
* @throws IllegalStateException if the value cannot be represented as a float.
*/
float asFloat();

/**
* Returns the value as a double.
* Returns this value as a double.
*
* @return the double value
* @throws IllegalStateException if the value cannot be represented as a double.
*/
double asDouble();

/**
* Returns the value as a char.
* Returns this value as a char.
*
* @return the char value
* @throws IllegalStateException if this annotation member value is not a char
*/
char asChar();

/**
* Returns the value as a String.
* Returns this value as a String.
*
* @return the String value
* @throws IllegalStateException if this annotation member value is not a String
*/
String asString();

/**
* Returns the value as an enum instance.
* Returns this enum value as an instance of the enum type.
*
* @param enumType the enum type
* @param <E> the enum generic type
* @return the enum instance
* @throws IllegalArgumentException if given {@code enumType} is not an enum type
* @throws IllegalStateException if this annotation member value is not an enum value
*/
// TODO we should be able to remove the Class<E> parameter
<E extends Enum<E>> E asEnum(Class<E> enumType);

/**
* Returns the enum type of the annotation member value.
* Returns the type of this enum value.
*
* @return a {@link ClassInfo} representing the enum type
* @throws IllegalStateException if this annotation member value is not an enum value
*/
ClassInfo<?> asEnumClass();

/**
* Returns the enum constant of the annotation member value.
* Returns the name (also known as enum constant) of this enum value.
*
* @return the enum constant
* @throws IllegalStateException if this annotation member value is not an enum value
*/
String asEnumConstant();

/**
* Returns the class value, represented as a {@link Type}. It can possibly be:
* Returns this class value as a {@link Type}. It can possibly be:
* <ul>
* <li>the {@link jakarta.enterprise.lang.model.types.VoidType void} type;</li>
* <li>a {@link jakarta.enterprise.lang.model.types.PrimitiveType primitive} type;</li>
* <li>a {@link jakarta.enterprise.lang.model.types.ClassType class} type;</li>
* <li>an {@link jakarta.enterprise.lang.model.types.ArrayType array} type, whose component type
* is one of the previously mentioned types.</li>
* is a primitive type or a class type.</li>
* </ul>
*
* @return the class value, as a {@link Type}
Expand All @@ -302,16 +301,16 @@ default boolean isArray() {
Type asType();

/**
* Returns the nested annotation value as an {@link AnnotationInfo}.
* Returns this nested annotation value as an {@link AnnotationInfo}.
*
* @return an {@link AnnotationInfo} instance
* @throws IllegalStateException if this annotation member value is not a nested annotation
*/
AnnotationInfo<?> asNestedAnnotation();

/**
* Returns the array value as an immutable {@link List} of {@link AnnotationMemberValue}s.
* Returns an empty list if the array value is an empty array.
* Returns this array value as an immutable {@link List} of {@link AnnotationMemberValue}s.
* Returns an empty list if the array is empty.
*
* @return an immutable list of {@link AnnotationMemberValue}s
* @throws IllegalStateException if this annotation member value is not an array
Expand Down

0 comments on commit e968b9a

Please sign in to comment.