Class Annotation
- java.lang.Object
-
- org.openjdk.jmc.flightrecorder.writer.api.Annotation
-
public final class Annotation extends Object
A struct-like representation of a JFR annotation
-
-
Field Summary
Fields Modifier and Type Field Description static String
ANNOTATION_SUPER_TYPE_NAME
-
Constructor Summary
Constructors Constructor Description Annotation(Type type)
Create a new Annotation instanceAnnotation(Type type, String value)
Create a new Annotation instanceAnnotation(Type type, String value, Annotation... annotations)
Create a new Annotation instanceAnnotation(Type type, Consumer<TypedValueBuilder> builderCallback, Annotation... annotations)
Create a new Annotation instanceAnnotation(Type type, Map<String,? extends TypedFieldValue> attributes, Annotation... annotations)
Create a new Annotation instance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
List<Annotation>
getAnnotations()
Get the list of the associatedannotations
Map<String,? extends TypedFieldValue>
getAttributes()
Type
getType()
String
getValue()
<T> T
getValue(Class<T> valueType, String name)
Get the attribute value by its name and typeint
hashCode()
static boolean
isAnnotationType(Type type)
Check whether a particular Type is an annotation typeString
toString()
-
-
-
Field Detail
-
ANNOTATION_SUPER_TYPE_NAME
public static final String ANNOTATION_SUPER_TYPE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Annotation
public Annotation(Type type)
Create a new Annotation instance- Parameters:
type
- the annotation type (must have the value of ANNOTATION_SUPER_TYPE_NAME as its super type)- Throws:
IllegalArgumentException
- if the annotation type is not having the value of ANNOTATION_SUPER_TYPE_NAME as its super type
-
Annotation
public Annotation(Type type, String value)
Create a new Annotation instance- Parameters:
type
- the annotation type (must have the value of ANNOTATION_SUPER_TYPE_NAME as its super type)value
- the annotation value or null- Throws:
IllegalArgumentException
- if the annotation type is not having the value of ANNOTATION_SUPER_TYPE_NAME as its super type
-
Annotation
public Annotation(Type type, String value, Annotation... annotations)
Create a new Annotation instance- Parameters:
type
- the annotation type (must have the value of ANNOTATION_SUPER_TYPE_NAME as its super type)value
- the annotation value or nullannotations
- the annotations list attached to this annotation- Throws:
IllegalArgumentException
- if the annotation type is not having the value of ANNOTATION_SUPER_TYPE_NAME as its super type
-
Annotation
public Annotation(Type type, Map<String,? extends TypedFieldValue> attributes, Annotation... annotations)
Create a new Annotation instance- Parameters:
type
- the annotation type (must have the value of ANNOTATION_SUPER_TYPE_NAME as its super type)attributes
- the annotation attributes or nullannotations
- the annotations list attached to this annotation- Throws:
IllegalArgumentException
- if the annotation type is not having the value of ANNOTATION_SUPER_TYPE_NAME as its super type
-
Annotation
public Annotation(Type type, Consumer<TypedValueBuilder> builderCallback, Annotation... annotations)
Create a new Annotation instance- Parameters:
type
- the annotation type (must have the value of ANNOTATION_SUPER_TYPE_NAME as its super type)builderCallback
- the annotation attributes builder callback or nullannotations
- the annotations list attached to this annotation- Throws:
IllegalArgumentException
- if the annotation type is not having the value of ANNOTATION_SUPER_TYPE_NAME as its super type
-
-
Method Detail
-
isAnnotationType
public static boolean isAnnotationType(Type type)
Check whether a particular Type is an annotation type- Parameters:
type
- Type to check- Returns:
- {@linkplain true} if the type extends Annotation type
-
getAnnotations
public List<Annotation> getAnnotations()
Get the list of the associatedannotations
- Returns:
- the associated
annotations
-
getType
public Type getType()
- Returns:
- the annotation type
-
getValue
public String getValue()
- Returns:
- the annotation's attribute value or null if the attribute is an array
-
getValue
public <T> T getValue(Class<T> valueType, String name)
Get the attribute value by its name and type- Type Parameters:
T
- the expected value type- Parameters:
valueType
- the expected value typename
- the attribute name- Returns:
- the attribute value or null
- Throws:
IllegalArgumentException
- when the attribute's type is not assignable to the requested value type
-
getAttributes
public Map<String,? extends TypedFieldValue> getAttributes()
- Returns:
- the annotation's attribute array value or null if the attribute is not an array
-
-