@Mapping( "description" ) public ValueRepresentation getDescription() { return ValueRepresentation.string( data.getCompositeType() .getDescription() ); }
private Map<String, Object> toNeo4jValue( CompositeData composite ) { HashMap<String,Object> properties = new HashMap<>(); for ( String key : composite.getCompositeType().keySet() ) { properties.put( key, toNeo4jValue(composite.get( key )) ); } return map( "description", composite.getCompositeType().getDescription(), "properties", properties ); }
@Mapping( "value" ) public ListRepresentation getValue() { ArrayList<Representation> values = new ArrayList<>(); for ( Object key : data.getCompositeType().keySet() ) { String name = key.toString(); String description = data.getCompositeType().getDescription( name ); Representation value = REPRESENTATION_DISPATCHER.dispatch( data.get( name ), "" ); values.add( new NameDescriptionValueRepresentation( name, description, value ) ); } return new ListRepresentation( "value", values ); } }
key, typ, type.getDescription(), valu); name, typ, type.getDescription(), composite.get(valueIdx));
protected Map<String, Object> preprocessValueMap(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; } }
@Mapping( "description" ) public ValueRepresentation getDescription() { return ValueRepresentation.string( data.getCompositeType() .getDescription() ); }
private Map<String, Object> toNeo4jValue( CompositeData composite ) { HashMap<String,Object> properties = new HashMap<>(); for ( String key : composite.getCompositeType().keySet() ) { properties.put( key, toNeo4jValue(composite.get( key )) ); } return map( "description", composite.getCompositeType().getDescription(), "properties", properties ); }
private Map<String, Metric> convert(CompositeData compositeData) { CompositeType compositeType = compositeData.getCompositeType(); Map<String, Metric> metrics = new HashMap<String, Metric>( compositeType.keySet().size()); for (String statKey : compositeType.keySet()) { Object value = compositeData.get(statKey); if (value instanceof CompositeData) { value = convert((CompositeData) value); } String description = compositeType.getDescription(statKey); metrics.put(statKey, new Statistic<Object>( statKey, value, description)); } return Collections.unmodifiableMap(metrics); }
@Override public Optional<Map<String, Object>> mapAttribute(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); }
@Override public Map<String, Metric> getStatistics() { CompositeData compData = getMessageServiceStatisticsMBean().getMessagingStatistics(); CompositeType compType = compData.getCompositeType(); Map<String, Metric> statistics = new HashMap<String, Metric>( compType.keySet().size()); for (String statKey : compType.keySet()) { Object value = compData.get(statKey); String description = compType.getDescription(statKey); statistics.put(statKey, new Statistic<Object> ( statKey, value, description)); } return Collections.unmodifiableMap(statistics); } }
@Mapping( "value" ) public ListRepresentation getValue() { ArrayList<Representation> values = new ArrayList<>(); for ( Object key : data.getCompositeType().keySet() ) { String name = key.toString(); String description = data.getCompositeType().getDescription( name ); Representation value = REPRESENTATION_DISPATCHER.dispatch( data.get( name ), "" ); values.add( new NameDescriptionValueRepresentation( name, description, value ) ); } return new ListRepresentation( "value", values ); } }
for (Object nm : parent.keySet()) { String key = (String) nm; all.add(new Item((String) nm, parent.getDescription(key), parent.getType(key)));
for (Object nm : parent.keySet()) { String key = (String) nm; all.add(new Item(key, parent.getDescription(key), parent.getType(key)));
for (Object nm : parent.keySet()) { String key = (String) nm; all.add(new Item(key, parent.getDescription(key), parent.getType(key)));
for (Object nm : parent.keySet()) { String key = (String) nm; all.add(new Item(key, parent.getDescription(key), parent.getType(key)));
for (Object nm : parent.keySet()) { String key = (String) nm; all.add(new Item(key, parent.getDescription(key), parent.getType(key)));
descriptions[i] = getOpenType().getDescription(names[i]); itemTypes[i] = openTypes.get(innerAttrNameStr); i++; try { LOG.trace("Attribute {} with open type {}. Reconstructing open type.", attrName, getOpenType()); setOpenType(new CompositeType(getOpenType().getTypeName(), getOpenType().getDescription(), names, descriptions, itemTypes)); LOG.debug("Attribute {}. Open type reconstructed to {}", attrName, getOpenType(), getOpenType()); parsedValue = new CompositeDataSupport(getOpenType(), items);
for (Object key : data.getCompositeType().keySet()) { Object v = data.get((String) key); printExpression(output, key, v, data.getCompositeType().getDescription((String) key), indent + indentSize);
printExpression( output, key, v, data.getCompositeType().getDescription( (String) key ), indent + indentSize );
static ObjectNode serialize(final CompositeType openType){ final ObjectNode result = ThreadLocalJsonFactory.getFactory().objectNode(); result.put(TYPE_NAME_FIELD, openType.getTypeName()); result.put(DESCRIPTION_FIELD, openType.getDescription()); final ObjectNode items = ThreadLocalJsonFactory.getFactory().objectNode(); result.put(ITEMS_FIELD, items); for(final String itemName: openType.keySet()){ final ObjectNode item = ThreadLocalJsonFactory.getFactory().objectNode(); item.put(DESCRIPTION_FIELD, openType.getDescription(itemName)); item.put(TYPE_FIELD, serialize(openType.getType(itemName))); items.put(itemName, item); } return result; }