本文整理汇总了Java中javax.management.openmbean.CompositeType.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeType.keySet方法的具体用法?Java CompositeType.keySet怎么用?Java CompositeType.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.openmbean.CompositeType
的用法示例。
在下文中一共展示了CompositeType.keySet方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTypeMatched
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
/**
* Compares two CompositeTypes and returns true if
* all items in type1 exist in type2 and their item types
* are the same.
* @param type1 the base composite type
* @param type2 the checked composite type
* @return {@code true} if all items in type1 exist in type2 and their item
* types are the same.
*/
protected static boolean isTypeMatched(CompositeType type1, CompositeType type2) {
if (type1 == type2) return true;
// We can't use CompositeType.isValue() since it returns false
// if the type name doesn't match.
Set<String> allItems = type1.keySet();
// Check all items in the type1 exist in type2
if (!type2.keySet().containsAll(allItems))
return false;
return allItems.stream().allMatch(
item -> isTypeMatched(type1.getType(item), type2.getType(item))
);
}
示例2: preprocessValueMap
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
@Override
protected Map<String, Object> preprocessValueMap(final Map<?, ?> valueMap) {
CompositeType openType = getOpenType();
Preconditions.checkArgument(
valueMap.size() == 1 && valueMap.containsKey(JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION),
"Unexpected structure of incoming map, expecting one element under %s, but was %s",
JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION, valueMap);
Map<String, Object> newMap = Maps.newHashMap();
for (String key : openType.keySet()) {
if (openType.getDescription(key).equals(JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION)) {
newMap.put(key, valueMap.get(JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION));
} else {
newMap.put(key, null);
}
}
return newMap;
}
示例3: writeObject
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
private void writeObject(JsonGenerator jg, Object value) throws IOException {
if(value == null) {
jg.writeNull();
} else {
Class<?> c = value.getClass();
if (c.isArray()) {
jg.writeStartArray();
int len = Array.getLength(value);
for (int j = 0; j < len; j++) {
Object item = Array.get(value, j);
writeObject(jg, item);
}
jg.writeEndArray();
} else if(value instanceof Number) {
Number n = (Number)value;
jg.writeNumber(n.toString());
} else if(value instanceof Boolean) {
Boolean b = (Boolean)value;
jg.writeBoolean(b);
} else if(value instanceof CompositeData) {
CompositeData cds = (CompositeData)value;
CompositeType comp = cds.getCompositeType();
Set<String> keys = comp.keySet();
jg.writeStartObject();
for(String key: keys) {
writeAttribute(jg, key, cds.get(key));
}
jg.writeEndObject();
} else if(value instanceof TabularData) {
TabularData tds = (TabularData)value;
jg.writeStartArray();
for(Object entry : tds.values()) {
writeObject(jg, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}
示例4: isTypeMatched
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
/**
* Compares two CompositeTypes and returns true if
* all items in type1 exist in type2 and their item types
* are the same.
*/
protected static boolean isTypeMatched(CompositeType type1, CompositeType type2) {
if (type1 == type2) return true;
// We can't use CompositeType.isValue() since it returns false
// if the type name doesn't match.
Set<String> allItems = type1.keySet();
// Check all items in the type1 exist in type2
if (!type2.keySet().containsAll(allItems))
return false;
for (String item: allItems) {
OpenType<?> ot1 = type1.getType(item);
OpenType<?> ot2 = type2.getType(item);
if (ot1 instanceof CompositeType) {
if (! (ot2 instanceof CompositeType))
return false;
if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2))
return false;
} else if (ot1 instanceof TabularType) {
if (! (ot2 instanceof TabularType))
return false;
if (!isTypeMatched((TabularType) ot1, (TabularType) ot2))
return false;
} else if (!ot1.equals(ot2)) {
return false;
}
}
return true;
}
示例5: getVersionedCompositeType
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
/**
* Retrieves the specified version of a {@linkplain CompositeType} instance.
* @param type The current (latest) version of {@linkplain CompositeType}
* @param version The version identifier (eg. {@linkplain TypeVersionMapper#V5})
* @return Returns the {@linkplain CompositeType} corresponding to the requested
* version.
* @throws OpenDataException
*/
CompositeType getVersionedCompositeType(CompositeType type, String version)
throws OpenDataException
{
Predicate<String> filter = getFilter(type.getTypeName(), version);
if (filter == null) {
return type;
}
List<String> itemNames = new ArrayList<>();
List<String> itemDesc = new ArrayList<>();
List<OpenType<?>> itemTypes = new ArrayList<>();
for(String item : type.keySet()) {
if (filter.test(item)) {
itemNames.add(item);
itemDesc.add(type.getDescription(item));
itemTypes.add(getVersionedType(
type.getType(item),
version
));
}
}
return new CompositeType(
type.getTypeName(),
version != null ? version + " " + type.getDescription() : type.getDescription(),
itemNames.toArray(new String[itemNames.size()]),
itemDesc.toArray(new String[itemDesc.size()]),
itemTypes.toArray(new OpenType<?>[itemTypes.size()])
);
}
示例6: caseJavaCompositeAttribute
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
@Override
protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseJavaCompositeAttribute(
final CompositeType openType) {
Map<String, AttributeMappingStrategy<?, ? extends OpenType<?>>> innerStrategies = Maps.newHashMap();
Map<String, String> attributeMapping = Maps.newHashMap();
for (String innerAttributeKey : openType.keySet()) {
innerStrategies.put(innerAttributeKey, caseJavaAttribute(openType.getType(innerAttributeKey)));
attributeMapping.put(innerAttributeKey, innerAttributeKey);
}
return new CompositeAttributeMappingStrategy(openType, innerStrategies, attributeMapping);
}
示例7: caseJavaUnionAttribute
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
@Override
protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseJavaUnionAttribute(final OpenType<?> openType) {
Map<String, AttributeMappingStrategy<?, ? extends OpenType<?>>> innerStrategies = Maps.newHashMap();
Map<String, String> attributeMapping = Maps.newHashMap();
CompositeType compositeType = (CompositeType) openType;
for (String innerAttributeKey : compositeType.keySet()) {
innerStrategies.put(innerAttributeKey, caseJavaAttribute(compositeType.getType(innerAttributeKey)));
attributeMapping.put(innerAttributeKey, innerAttributeKey);
}
return new UnionCompositeAttributeMappingStrategy(compositeType, innerStrategies, attributeMapping);
}
示例8: mapAttribute
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
@Override
public Optional<Map<String, Object>> mapAttribute(final Object value) {
if (value == null) {
return Optional.absent();
}
Util.checkType(value, CompositeDataSupport.class);
CompositeDataSupport compositeData = (CompositeDataSupport) value;
CompositeType currentType = compositeData.getCompositeType();
CompositeType expectedType = getOpenType();
Set<String> expectedCompositeTypeKeys = expectedType.keySet();
Set<String> currentCompositeTypeKeys = currentType.keySet();
Preconditions.checkArgument(expectedCompositeTypeKeys.equals(currentCompositeTypeKeys),
"Composite type mismatch, expected composite type with attributes " + expectedCompositeTypeKeys
+ " but was " + currentCompositeTypeKeys);
Map<String, Object> retVal = Maps.newHashMap();
for (String jmxName : jmxToJavaNameMapping.keySet()) {
Optional<?> mapped = mapInnerAttribute(compositeData, jmxName, expectedType.getDescription(jmxName));
if (mapped.isPresent()) {
retVal.put(jmxToJavaNameMapping.get(jmxName), mapped.get());
}
}
return Optional.of(retVal);
}
示例9: fillMappingForComposite
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
private void fillMappingForComposite(final CompositeType openType,
final Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerMap,
final Map<String, String> yangToJmxMapping) {
for (String innerAttributeKey : openType.keySet()) {
innerMap.put(innerAttributeKey, caseJavaAttribute(openType.getType(innerAttributeKey)));
yangToJmxMapping.put(innerAttributeKey, innerAttributeKey);
}
}
示例10: caseTOAttribute
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
@Override
protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseTOAttribute(final CompositeType openType) {
Preconditions.checkState(getLastAttribute() instanceof TOAttribute);
TOAttribute toAttribute = (TOAttribute) getLastAttribute();
Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerMap = Maps.newHashMap();
for (String innerName : openType.keySet()) {
AttributeIfc innerAttributeIfc = toAttribute.getJmxPropertiesToTypesMap().get(innerName);
innerMap.put(innerAttributeIfc.getAttributeYangName(), prepareStrategy(innerAttributeIfc));
}
return new CompositeAttributeResolvingStrategy(innerMap, openType, createYangToJmxMapping(toAttribute));
}
示例11: writeObject
import javax.management.openmbean.CompositeType; //导入方法依赖的package包/类
private static void writeObject(final JsonGenerator jg, final boolean description, Object value)
throws IOException {
if(value == null) {
jg.writeNull();
} else {
Class<?> c = value.getClass();
if (c.isArray()) {
jg.writeStartArray();
int len = Array.getLength(value);
for (int j = 0; j < len; j++) {
Object item = Array.get(value, j);
writeObject(jg, description, item);
}
jg.writeEndArray();
} else if(value instanceof Number) {
Number n = (Number)value;
jg.writeNumber(n.toString());
} else if(value instanceof Boolean) {
Boolean b = (Boolean)value;
jg.writeBoolean(b);
} else if(value instanceof CompositeData) {
CompositeData cds = (CompositeData)value;
CompositeType comp = cds.getCompositeType();
Set<String> keys = comp.keySet();
jg.writeStartObject();
for (String key: keys) {
writeAttribute(jg, key, null, cds.get(key));
}
jg.writeEndObject();
} else if(value instanceof TabularData) {
TabularData tds = (TabularData)value;
jg.writeStartArray();
for(Object entry : tds.values()) {
writeObject(jg, description, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}