/** * Returns a CSV string representation of the property value. * * @param p property value * @return CSV string */ private String propertyValueToCsvString(PropertyValue p) { if (p.isList() || p.isSet()) { return collectionToCsvString((Collection) p.getObject()); } else if (p.isMap()) { return p.getMap().entrySet().stream() .map(e -> escape(e.getKey()) + CSVConstants.MAP_SEPARATOR + escape(e.getValue())) .collect(Collectors.joining(CSVConstants.LIST_DELIMITER, "{", "}")); } else { return escape(p); } }
/** * Returns a CSV string representation of the property value. * * @param p property value * @return CSV string */ private String propertyValueToCsvString(PropertyValue p) { if (p.isList() || p.isSet()) { return collectionToCsvString((Collection) p.getObject()); } else if (p.isMap()) { return p.getMap().entrySet().stream() .map(e -> escape(e.getKey()) + CSVConstants.MAP_SEPARATOR + escape(e.getValue())) .collect(Collectors.joining(CSVConstants.LIST_DELIMITER, "{", "}")); } else { return escape(p); } }
@Test public void testGetMap() throws Exception { PropertyValue p = PropertyValue.create(MAP_VAL_9); assertEquals(MAP_VAL_9, p.getMap()); }
@Test public void testSetMap() throws Exception { PropertyValue p = new PropertyValue(); p.setMap(MAP_VAL_9); assertEquals(MAP_VAL_9, p.getMap()); }
@Test public void testVariableMappingCreation() throws Exception { AddGraphElementToNewGraph<Vertex> udf = new AddGraphElementToNewGraph<>(new GraphHeadFactory(), "a"); Vertex vertex = new VertexFactory().createVertex(); Tuple2<Vertex, GraphHead> result = udf.map(vertex); assertTrue(result.f1.hasProperty(PatternMatching.VARIABLE_MAPPING_KEY)); Map<PropertyValue, PropertyValue> variableMapping = result.f1.getPropertyValue(PatternMatching.VARIABLE_MAPPING_KEY).getMap(); assertEquals(vertex.getId(), variableMapping.get(PropertyValue.create("a")).getGradoopId()); } }
= graphHead.getPropertyValue(PatternMatching.VARIABLE_MAPPING_KEY).getMap();
/** * Returns the wrapped value as object. * * @return value or {@code null} if the value is empty */ public Object getObject() { return isBoolean() ? getBoolean() : isShort() ? getShort() : isInt() ? getInt() : isLong() ? getLong() : isFloat() ? getFloat() : isDouble() ? getDouble() : isString() ? getString() : isBigDecimal() ? getBigDecimal() : isGradoopId() ? getGradoopId() : isMap() ? getMap() : isList() ? getList() : isDate() ? getDate() : isTime() ? getTime() : isDateTime() ? getDateTime() : isSet() ? getSet() : null; } /**
assertEquals(epgmElement.getPropertyValue(GradoopTestUtils.KEY_a).getBigDecimal(), PROPERTY_MAP.get(GradoopTestUtils.KEY_a)); assertEquals(epgmElement.getPropertyValue(GradoopTestUtils.KEY_b).getMap(), PROPERTY_MAP.get(GradoopTestUtils.KEY_b)); assertEquals(epgmElement.getPropertyValue(GradoopTestUtils.KEY_c).getList(),
case KEY_9: assertTrue(v.getPropertyValue(propertyKey).isMap()); assertEquals(MAP_VAL_9, v.getPropertyValue(propertyKey).getMap()); break; case KEY_a:
case KEY_9: assertTrue(v.getPropertyValue(propertyKey).isMap()); assertEquals(MAP_VAL_9, v.getPropertyValue(propertyKey).getMap()); break; case KEY_a:
assertEquals(MAP_VAL_9, p.getMap());