Search in sources :

Example 6 with ListValueBuilder

use of org.neo4j.values.virtual.ListValueBuilder in project neo4j by neo4j.

the class RoutingResultFormat method build.

public static AnyValue[] build(RoutingResult result) {
    ListValue routers = asValues(result.routeEndpoints());
    ListValue readers = asValues(result.readEndpoints());
    ListValue writers = asValues(result.writeEndpoints());
    ListValueBuilder servers = ListValueBuilder.newListBuilder();
    if (writers.size() > 0) {
        MapValueBuilder builder = new MapValueBuilder();
        builder.add(ROLE_KEY, WRTE_NAME);
        builder.add(ADDRESSES_KEY, writers);
        servers.add(builder.build());
    }
    if (readers.size() > 0) {
        MapValueBuilder builder = new MapValueBuilder();
        builder.add(ROLE_KEY, READ_NAME);
        builder.add(ADDRESSES_KEY, readers);
        servers.add(builder.build());
    }
    if (routers.size() > 0) {
        MapValueBuilder builder = new MapValueBuilder();
        builder.add(ROLE_KEY, ROUTE_NAME);
        builder.add(ADDRESSES_KEY, routers);
        servers.add(builder.build());
    }
    LongValue timeToLiveSeconds = longValue(MILLISECONDS.toSeconds(result.ttlMillis()));
    return new AnyValue[] { timeToLiveSeconds, servers.build() };
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder) ListValue(org.neo4j.values.virtual.ListValue) LongValue(org.neo4j.values.storable.LongValue) AnyValue(org.neo4j.values.AnyValue) ListValueBuilder(org.neo4j.values.virtual.ListValueBuilder)

Aggregations

ListValueBuilder (org.neo4j.values.virtual.ListValueBuilder)6 AnyValue (org.neo4j.values.AnyValue)3 LongValue (org.neo4j.values.storable.LongValue)2 ListValue (org.neo4j.values.virtual.ListValue)2 MapValueBuilder (org.neo4j.values.virtual.MapValueBuilder)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Stream (java.util.stream.Stream)1 Entity (org.neo4j.graphdb.Entity)1 InputPosition (org.neo4j.graphdb.InputPosition)1 Node (org.neo4j.graphdb.Node)1 Notification (org.neo4j.graphdb.Notification)1 Path (org.neo4j.graphdb.Path)1 Relationship (org.neo4j.graphdb.Relationship)1 Geometry (org.neo4j.graphdb.spatial.Geometry)1 Point (org.neo4j.graphdb.spatial.Point)1 BooleanValue (org.neo4j.values.storable.BooleanValue)1 DoubleValue (org.neo4j.values.storable.DoubleValue)1 IntValue (org.neo4j.values.storable.IntValue)1