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() };
}
Aggregations