- java.lang.Object
-
- jdk.jfr.EventType
-
public final class EventType extends Object
Describes an event, its fields, settings and annotations.- Since:
- 9
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Annotation>
AgetAnnotation(Class<A> annotationClass)
Returns the first annotation for the specified type if an annotation element with the same name is directly present, elsenull
.List<AnnotationElement>
getAnnotationElements()
Returns an immutable list of annotation elements for this event type.List<String>
getCategoryNames()
Returns the list of human-readable names that makes up the category for this event type, for instance "Java Application", "Statistics".String
getDescription()
Returns a short sentence that describes the event class.static EventType
getEventType(Class<? extends Event> eventClass)
Returns the event type for an event class, ornull
if not present.ValueDescriptor
getField(String name)
Returns the field with the specified name, ornull
if it doesn't exist.List<ValueDescriptor>
getFields()
Returns an immutable list of descriptors describing the event fields of this event type.long
getId()
Returns a unique id for the event in the JVM.String
getLabel()
Returns a human-readable name, for example"CPU Load"
.String
getName()
Returns an identifier for the event, for example"jdk.jfr.CPULoad"
.List<SettingDescriptor>
getSettingDescriptors()
Returns an immutable list of setting descriptors that describes available event settings for thisEventType
.boolean
isEnabled()
Returnstrue
if event is enabled and at least one recording is running,false
otherwise.
-
-
-
Method Detail
-
getFields
public List<ValueDescriptor> getFields()
Returns an immutable list of descriptors describing the event fields of this event type.- Returns:
- the list of field descriptors, not
null
-
getField
public ValueDescriptor getField(String name)
Returns the field with the specified name, ornull
if it doesn't exist.- Returns:
- a value descriptor describing the field, or
null
if the field with given name doesn't exist
-
getName
public String getName()
Returns an identifier for the event, for example"jdk.jfr.CPULoad"
.The name is the fully qualified name of the event class, if not set using the
Name
annotation.- Returns:
- the name, not
null
- See Also:
Name
-
getLabel
public String getLabel()
Returns a human-readable name, for example"CPU Load"
.The label of an event class can be set with
Label
.- Returns:
- the label, or
null
if a label has not been set - See Also:
Label
-
getId
public long getId()
Returns a unique id for the event in the JVM.- Returns:
- the id
-
getAnnotationElements
public List<AnnotationElement> getAnnotationElements()
Returns an immutable list of annotation elements for this event type.- Returns:
- an immutable list of annotation or an empty list if no
annotations exists, not
null
-
isEnabled
public boolean isEnabled()
Returnstrue
if event is enabled and at least one recording is running,false
otherwise.By default events are enabled, but behavior can be changed by annotating event with
@Enabled(false)
. Enablement can always be overridden by setting the "enabled" setting to "true" or "false", programmatically or by using a configuration file.- Returns:
- true if event is enabled, false otherwise
- See Also:
Enabled
,Recording.enable(Class)
-
getDescription
public String getDescription()
Returns a short sentence that describes the event class.The description of an event class can be set with
Description
.- Returns:
- the description, or
null
if no description exists - See Also:
Description
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
Returns the first annotation for the specified type if an annotation element with the same name is directly present, elsenull
.- Type Parameters:
A
- the type of the annotation to query for and return if present- Parameters:
annotationClass
- theClass
object corresponding to the annotation type, notnull
- Returns:
- this element's annotation for the specified annotation type if
directly present, else
null
-
getEventType
public static EventType getEventType(Class<? extends Event> eventClass)
Returns the event type for an event class, ornull
if not present.- Parameters:
eventClass
- the event class, notnull
- Returns:
- the event class, or null if class is not available
- Throws:
IllegalArgumentException
- ifeventClass
is an abstract classIllegalStateException
- if the class was annotated withRegistered(false)
, but never registered manually
-
getSettingDescriptors
public List<SettingDescriptor> getSettingDescriptors()
Returns an immutable list of setting descriptors that describes available event settings for thisEventType
.- Returns:
- the list of setting descriptors for this event type, not
null
-
getCategoryNames
public List<String> getCategoryNames()
Returns the list of human-readable names that makes up the category for this event type, for instance "Java Application", "Statistics".- Returns:
- an immutable list of category names, or a list with the name "Uncategorized" if no category has been set
- See Also:
Category
-
-