Example usage for javax.management.openmbean CompositeType containsKey

List of usage examples for javax.management.openmbean CompositeType containsKey

Introduction

In this page you can find the example usage for javax.management.openmbean CompositeType containsKey.

Prototype

public boolean containsKey(String itemName) 

Source Link

Document

Returns true if this CompositeType instance defines an item whose name is itemName.

Usage

From source file:org.jolokia.converter.object.TabularDataConverter.java

private boolean checkForMapValue(TabularType pType) {
    CompositeType rowType = pType.getRowType();
    // Two entries in the row: "key" and "value"
    return rowType.containsKey(TD_KEY_VALUE) && rowType.containsKey(TD_KEY_KEY) && rowType.keySet().size() == 2;
}

From source file:org.jolokia.converter.json.TabularDataExtractor.java

/**
 * Check whether the given tabular type represents a MXBean map. See the
 * {@link javax.management.MXBean} specification for
 * details how a map is converted to {@link TabularData} by the MXBean framework.
 *
 * @param pType type of tabular data to convert
 * @return true if this type represents an MXBean map, false otherwise.
 *///from  w  w w  .  ja v a2s. c om
private boolean checkForMxBeanMap(TabularType pType) {
    CompositeType rowType = pType.getRowType();
    return rowType.containsKey("key") && rowType.containsKey("value") && rowType.keySet().size() == 2
    // Only convert to map for simple types for all others use normal conversion. See #105 for details.
            && rowType.getType("key") instanceof SimpleType;
}

From source file:org.jolokia.converter.object.CompositeTypeConverter.java

private void fillCompositeWithGivenValues(CompositeType pType, Map<String, Object> pCompositeValues,
        Map<String, Object> pSourceJson) {
    for (Map.Entry<String, Object> entry : pSourceJson.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();

        if (!pType.containsKey(key)) {
            throw new IllegalArgumentException("Conversion to CompositeType failed because " + key
                    + " is not known as composite attribute key.");
        }//  w w  w .  ja v a  2  s. c om
        if (value != null) {
            Object convertedValue = getDispatcher().convertToObject(pType.getType(key), value);
            pCompositeValues.put(key, convertedValue);
        }
    }
}