swg.getStrategy().setGraphStrategy(new SequenceGraphStrategy(
new GraphStrategy() {
@Override
public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final Strategy.Context ctx) {
return (f) -> (args) -> {
final Vertex v = f.apply(args);
// this means that the next strategy and those below it executed including
// the implementation
assertEquals("working2", v.property("anonymous").value());
// now do something with that vertex after the fact
v.properties("anonymous").remove();
v.property("anonymous", "working1");
return v;
};
}
},
new GraphStrategy() {
@Override
public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final Strategy.Context ctx) {
return (f) -> (args) -> {
final Vertex v = f.apply(args);
// this means that the next strategy and those below it executed including
// the implementation
assertEquals("working3", v.property("anonymous").value());
// now do something with that vertex after the fact
v.properties("anonymous").remove();
v.property("anonymous", "working2");
return v;
};
}
},
new GraphStrategy() {
@Override
public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final Strategy.Context ctx) {
return (f) -> (args) -> {
final List<Object> o = new ArrayList<>(Arrays.asList(args));
o.addAll(Arrays.asList("anonymous", "working3"));
return f.apply(o.toArray());
};
}
}
));
final Vertex v = swg.addVertex("any", "thing");
assertNotNull(v);
assertEquals("thing", v.property("any").value());
assertEquals("working1", v.property("anonymous").value());
}