@Override public void writeRelationship( long relId, long startNodeId, long endNodeId, TextValue type, MapValue properties ) { append( format( "-[id=%d :%s", relId, type.stringValue() ) ); if ( properties.size() > 0 ) { append( " " ); properties.writeTo( this ); } append( "]-" ); }
@Override public void writeRelationship( long relationshipId, long startNodeId, long endNodeId, TextValue type, MapValue properties ) throws IOException { packStructHeader( RELATIONSHIP_SIZE, RELATIONSHIP ); pack( relationshipId ); pack( startNodeId ); pack( endNodeId ); type.writeTo( this ); properties.writeTo( this ); }
@Test public void shouldHandleMapsWithLists() { // Given MapValue map = map( new String[]{"foo", "bar"}, new AnyValue[]{longValue( 42L ), list( stringValue( "baz" ) )} ); // When map.writeTo( converter ); // Then Map<?,?> value = (Map<?,?>) converter.value(); assertThat( value.get( "foo" ), equalTo( 42L ) ); assertThat( value.get( "bar" ), equalTo( singletonList( "baz" ) ) ); assertThat( value.size(), equalTo( 2 ) ); } }
@Override public void writeNode( long nodeId, TextArray labels, MapValue properties ) { append( format( "(id=%d", nodeId ) ); String sep = " "; for ( int i = 0; i < labels.length(); i++ ) { append( sep ); append( ":" + labels.stringValue( i ) ); sep = ""; } if ( properties.size() > 0 ) { append( " " ); properties.writeTo( this ); } append( ")" ); }
@Override public void writeNode( long nodeId, TextArray labels, MapValue properties ) throws IOException { packStructHeader( NODE_SIZE, NODE ); pack( nodeId ); packListHeader( labels.length() ); for ( int i = 0; i < labels.length(); i++ ) { labels.value( i ).writeTo( this ); } properties.writeTo( this ); }
@Test void shouldHandleMaps() { // Given PrettyPrinter printer = new PrettyPrinter(); MapValue mapValue = props( "k1", intValue( 42 ) ); // When mapValue.writeTo( printer ); // Then assertThat( printer.value(), equalTo( "{k1: 42}" ) ); }
@Test public void shouldHandleMaps() { // Given MapValue map = map( new String[]{"foo", "bar"}, new AnyValue[]{longValue( 42L ), stringValue( "baz" )} ); // When map.writeTo( converter ); // Then assertThat( converter.value(), equalTo( MapUtil.map( "foo", 42L, "bar", "baz" ) ) ); }
pack( edge.id() ); edge.type().writeTo( this ); edge.properties().writeTo( this );
@Override public void writeRelationship( long relId, long startNodeId, long endNodeId, TextValue type, MapValue properties ) { append( format( "-[id=%d :%s", relId, type.stringValue() ) ); if ( properties.size() > 0 ) { append( " " ); properties.writeTo( this ); } append( "]-" ); }
@Override public void writeRelationship( long relationshipId, long startNodeId, long endNodeId, TextValue type, MapValue properties ) throws IOException { packStructHeader( RELATIONSHIP_SIZE, RELATIONSHIP ); pack( relationshipId ); pack( startNodeId ); pack( endNodeId ); type.writeTo( this ); properties.writeTo( this ); }
@Override public void writeNode( long nodeId, TextArray labels, MapValue properties ) { append( format( "(id=%d", nodeId ) ); String sep = " "; for ( int i = 0; i < labels.length(); i++ ) { append( sep ); append( ":" + labels.stringValue( i ) ); sep = ""; } if ( properties.size() > 0 ) { append( " " ); properties.writeTo( this ); } append( ")" ); }
@Override public void writeNode( long nodeId, TextArray labels, MapValue properties ) throws IOException { packStructHeader( NODE_SIZE, NODE ); pack( nodeId ); packListHeader( labels.length() ); for ( int i = 0; i < labels.length(); i++ ) { labels.value( i ).writeTo( this ); } properties.writeTo( this ); }
pack( edge.id() ); edge.type().writeTo( this ); edge.properties().writeTo( this );