- java.lang.Object
-
- jdk.jfr.ValueDescriptor
-
public final class ValueDescriptor extends Object
Describes event fields and annotation elements.- Since:
- 9
-
-
Constructor Summary
Constructors Constructor Description ValueDescriptor(Class<?> type, String name)Constructs a value descriptor, useful for creating event types and annotations dynamically.ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations)Constructs a value descriptor, useful for creating event types and annotations dynamically.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Annotation>
AgetAnnotation(Class<A> annotationType)Returns the first annotation for the specified type if an annotation element with the same name is directly present for this value descriptor, elsenull.List<AnnotationElement>getAnnotationElements()Returns an immutable list of annotation elements for this value descriptor.StringgetContentType()Returns a textual identifier that determines how a value represented by thisValueDescriptorshould be interpreted or formatted.StringgetDescription()Returns a sentence describing the value, for example"Maximum throughput in the transaction system. Value is reset after each new batch".List<ValueDescriptor>getFields()Returns an immutable list of value descriptor if the type is complex, else an empty list.StringgetLabel()Returns a human-readable name describing the value, for example"Maximum Throughput".StringgetName()Returns the name of the value, for example"maxThroughput".longgetTypeId()Returns a unique identifier for the type in the JVM.StringgetTypeName()Returns the fully qualified class name of the type associated with this value descriptor.booleanisArray()Returns if this value descriptor is an array type.
-
-
-
Constructor Detail
-
ValueDescriptor
public ValueDescriptor(Class<?> type, String name)
Constructs a value descriptor, useful for creating event types and annotations dynamically.
Supported types are
byte.classshort.classint.classlong.classchar.classfloat.classdouble.classboolean.classString.classClass.classThread.class
A valid Java identifier, for example
"maxThroughput". See 3.8 Java Language Specification for more information.- Parameters:
type- the type, notnullname- the name, notnull- Throws:
SecurityException- if a security manager is present and the caller doesn't haveFlightRecorderPermission("registerEvent")
-
ValueDescriptor
public ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations)
Constructs a value descriptor, useful for creating event types and annotations dynamically.
Supported types are
byte.classshort.classint.classlong.classchar.classfloat.classdouble.classboolean.classString.classClass.classThread.class
A valid Java identifier, for example
"maxThroughput". See 3.8 Java Language Specification for more information.- Parameters:
type- the type, notnullname- the name, notnullannotations- the annotations on the value descriptors, notnull- Throws:
SecurityException- if a security manager is present and the caller doesn't haveFlightRecorderPermission"registerEvent"}
-
-
Method Detail
-
getLabel
public String getLabel()
Returns a human-readable name describing the value, for example"Maximum Throughput".- Returns:
- a human-readable name, or
nullif not available
-
getName
public String getName()
Returns the name of the value, for example"maxThroughput".- Returns:
- the name, not
null
-
getDescription
public String getDescription()
Returns a sentence describing the value, for example"Maximum throughput in the transaction system. Value is reset after each new batch".- Returns:
- the description, or
nullif not available
-
getContentType
public String getContentType()
Returns a textual identifier that determines how a value represented by thisValueDescriptorshould be interpreted or formatted.For example, if the value descriptor's type is
floatand the event value is0.5f, a content type of"jdk.jfr.Percentage"hints to a client that the value is a percentage and that it should be rendered as"50%".The JDK comes with the following predefined content types,
- jdk.jfr.Percentage
- jdk.jfr.Timespan
- jdk.jfr.Timestamp
- jdk.jfr.Frequency
- jdk.jfr.Flag
- jdk.jfr.MemoryAddress
- jdk.jfr.MemoryAmount
- jdk.jfr.NetworkAddress
User defined content types can be created using
ContentType.- Returns:
- the content type, or
nullif not available - See Also:
ContentType
-
getTypeName
public String getTypeName()
Returns the fully qualified class name of the type associated with this value descriptor.- Returns:
- the type name, not
null - See Also:
getTypeId()
-
getTypeId
public long getTypeId()
Returns a unique identifier for the type in the JVM. The id is not guaranteed to be the same between JVM instances.- Returns:
- type id, not negative
-
isArray
public boolean isArray()
Returns if this value descriptor is an array type.- Returns:
trueif it is an array type,falseotherwise
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> annotationType)
Returns the first annotation for the specified type if an annotation element with the same name is directly present for this value descriptor, elsenull.- Type Parameters:
A- the type of the annotation to query for and return if present- Parameters:
annotationType- the Class object corresponding to the annotation type, notnull- Returns:
- this element's annotation for the specified annotation type if
directly present, else
null
-
getAnnotationElements
public List<AnnotationElement> getAnnotationElements()
Returns an immutable list of annotation elements for this value descriptor.- Returns:
- a list of annotations, not
null
-
getFields
public List<ValueDescriptor> getFields()
Returns an immutable list of value descriptor if the type is complex, else an empty list.- Returns:
- a list of value descriptors, not
null
-
-