Example usage for javax.management Descriptor getFieldNames

List of usage examples for javax.management Descriptor getFieldNames

Introduction

In this page you can find the example usage for javax.management Descriptor getFieldNames.

Prototype

public String[] getFieldNames();

Source Link

Document

Returns all the field names in the descriptor.

Usage

From source file:com.proofpoint.jmx.MBeanRepresentation.java

private static Map<String, Object> toMap(Descriptor descriptor) {
    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    for (String fieldName : descriptor.getFieldNames()) {
        Object fieldValue = descriptor.getFieldValue(fieldName);
        if (fieldValue != null) {
            if (fieldValue instanceof Descriptor) {
                fieldValue = toMap((Descriptor) fieldValue);
            }/*from  w  w w . ja v  a 2 s.c  om*/
            builder.put(fieldName, fieldValue);
        }
    }
    ImmutableMap<String, Object> map = builder.build();
    if (!map.isEmpty()) {
        return map;
    } else {
        return null;
    }
}