Module jdk.jfr
Package jdk.jfr

Class ValueDescriptor

java.lang.Object
jdk.jfr.ValueDescriptor

public final class ValueDescriptor extends Object
Describes the event fields and annotation elements.

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());
        }
    }
}
Since:
9