org.neo4j.driver.internal.value.StringValue Java Examples
The following examples show how to use
org.neo4j.driver.internal.value.StringValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Neo4jMappingContextTest.java From sdn-rx with Apache License 2.0 | 6 votes |
@Test void complexPropertyWithConverterShouldNotBeConsideredAsAssociation() { class ConvertibleTypeConverter implements GenericConverter { @Override public Set<ConvertiblePair> getConvertibleTypes() { // in the real world this should also define the opposite way return singleton(new ConvertiblePair(ConvertibleType.class, StringValue.class)); } @Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { // no implementation needed for this test return null; } } Neo4jMappingContext schema = new Neo4jMappingContext( new Neo4jConversions(singleton(new ConvertibleTypeConverter()))); Neo4jPersistentEntity<?> entity = schema.getPersistentEntity(EntityWithConvertibleProperty.class); assertThat(entity.getPersistentProperty("convertibleType").isRelationship()).isFalse(); }
Example #2
Source File: Neo4jBoltPersistReader.java From streams with Apache License 2.0 | 6 votes |
@Nullable @Override public ObjectNode apply(@Nullable Value value) { ObjectNode resultNode = null; if (value instanceof StringValue) { StringValue stringValue = (StringValue) value; String string = stringValue.asLiteralString(); try { resultNode = mapper.readValue(string, ObjectNode.class); } catch (IOException ex) { LOGGER.error("IOException", ex); } } else if ( value instanceof NodeValue) { NodeValue nodeValue = (NodeValue) value; Node node = nodeValue.asNode(); Map<String, Object> nodeMap = node.asMap(); resultNode = PropertyUtil.getInstance(mapper).unflattenMap(nodeMap); } else if (value instanceof RelationshipValue) { RelationshipValue relationshipValue = (RelationshipValue) value; Relationship relationship = relationshipValue.asRelationship(); Map<String, Object> relationshipMap = relationship.asMap(); resultNode = PropertyUtil.getInstance(mapper).unflattenMap(relationshipMap); } return resultNode; }
Example #3
Source File: ThingWithCustomTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (StringValue.class.isAssignableFrom(sourceType.getType())) { return CustomType.of(((StringValue) source).asString()); } else { return Values.value(((CustomType) source).getValue()); } }