public final class ValueDescriptor extends Object
 The following example shows how the ValueDescriptor class can be used to list field information of all types. 
void printTypes() {
    Map<String, List<ValueDescriptor>> typeMap = new LinkedHashMap<>();
    for (EventType eventType : FlightRecorder.getFlightRecorder().getEventTypes()) {
        findTypes(typeMap, eventType.getName(), eventType.getFields());
    }
    for (String type : typeMap.keySet()) {
        System.out.println("Type: " + type);
        for (ValueDescriptor field : typeMap.get(type)) {
            System.out.println(" Field: " + field.getName());
            String arrayBrackets = field.isArray() ? "[]" : "";
            System.out.println("  Type: " + field.getTypeName() + arrayBrackets);
            if (field.getLabel() != null) {
                System.out.println("  Label: " + field.getLabel());
            }
            if (field.getDescription() != null) {
                System.out.println("  Description: " + field.getDescription());
            }
            if (field.getContentType() != null) {
                System.out.println("  Content Types: " + field.getContentType());
            }
        }
        System.out.println();
    }
}
void findTypes(Map<String, List<ValueDescriptor>> typeMap, String typeName, List<ValueDescriptor> fields) {
    if (!typeMap.containsKey(typeName)) {
        typeMap.put(typeName, fields);
        for (ValueDescriptor subField : fields) {
            findTypes(typeMap, subField.getTypeName(), subField.getFields());
        }
    }
}
| Constructor | Description | 
|---|---|
| ValueDescriptor |  Constructs a value descriptor, useful for dynamically creating event types and annotations. | 
| ValueDescriptor |  Constructs a value descriptor, useful for dynamically creating event types and annotations. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| <A extends Annotation> | getAnnotation | Returns the first annotation for the specified type if an annotation element with the same name is directly present for this value descriptor,  nullotherwise. | 
| List | getAnnotationElements() | Returns an immutable list of annotation elements for this value descriptor. | 
| String | getContentType() | Returns a textual identifier that specifies how a value represented by this  ValueDescriptoris interpreted or formatted. | 
| String | getDescription() | Returns a sentence describing the value (for example,  "Maximum
 throughput in the transaction system. Value is reset after each new
 batch."). | 
| List | getFields() | Returns an immutable list of value descriptors if the type is complex, else an empty list. | 
| String | getLabel() | Returns a human-readable name that describes the value (for example,  "Maximum Throughput"). | 
| String | getName() | Returns the name of the value (for example,  "maxThroughput"). | 
| long | getTypeId() | Returns a unique ID for the type in the Java virtual Machine (JVM). | 
| String | getTypeName() | Returns the fully qualified class name of the type that is associated with this value descriptor. | 
| boolean | isArray() | Returns if this value descriptor is an array type. | 
public ValueDescriptor(Class<?> type, String name)
Constructs a value descriptor, useful for dynamically creating event types and annotations.
The following types are supported:
byte.class short.class int.class long.class char.class float.class double.class boolean.class String.class Class.class Thread.class  The name must be a valid Java identifier (for example, "maxThroughput"). See section 3.8 and 3.9 of the Java Language Specification for more information.
type - the type, not null
name - the name, not null
IllegalArgumentException - if the name is not a valid Java identifierSecurityException - if a security manager is present and the caller doesn't have FlightRecorderPermission("registerEvent")
public ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations)
Constructs a value descriptor, useful for dynamically creating event types and annotations.
The following types are supported:
byte.class short.class int.class long.class char.class float.class double.class boolean.class String.class Class.class Thread.class  The name must be a valid Java identifier (for example, "maxThroughput"). See section 3.8 and 3.9 of the Java Language Specification for more information.
type - the type, not null
name - the name, not null
annotations - the annotations on the value descriptors, not null
IllegalArgumentException - if the name is not a valid Java identifierSecurityException - if a security manager is present and the caller doesn't have FlightRecorderPermission("registerEvent")
public String getLabel()
"Maximum Throughput").null if doesn't existpublic String getName()
"maxThroughput").null
public String getDescription()
"Maximum
 throughput in the transaction system. Value is reset after each new
 batch.").null if doesn't existpublic String getContentType()
ValueDescriptor is interpreted or formatted.  For example, if the value descriptor's type is float and the event value is 0.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 provides the following predefined content types:
 User-defined content types can be created by using the ContentType class.
null if doesn't existpublic String getTypeName()
null
public long getTypeId()
public boolean isArray()
true if it is an array type, false otherwisepublic <A extends Annotation> A getAnnotation(Class<A> annotationType)
null otherwise.A - the type of the annotation to query for and return if presentannotationType - the Class object that corresponds to the annotation type, not null
null
public List<AnnotationElement> getAnnotationElements()
null
public List<ValueDescriptor> getFields()
null
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/ValueDescriptor.html