Java Code Examples for org.neo4j.driver.internal.value.StringValue

The following examples show how to use org.neo4j.driver.internal.value.StringValue. These examples are extracted from open source projects. 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 Project: sdn-rx   Source File: Neo4jMappingContextTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: streams   Source File: Neo4jBoltPersistReader.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: sdn-rx   Source File: ThingWithCustomTypes.java    License: Apache License 2.0 5 votes vote down vote up
@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());
	}
}