@Override public Path transform(P_Inverse path, Path subPath) { Path result = subPath instanceof P_Link ? new P_ReverseLink(((P_Path0)subPath).getNode()) : new P_Inverse(subPath); // Path result = // subPath instanceof P_Inverse ? ((P_Inverse)subPath).getSubPath() : // subPath instanceof P_Link ? new P_ReverseLink(((P_Path0)subPath).getNode()) : // subPath instanceof P_ReverseLink ? new P_Link(((P_Path0)subPath).getNode()) : // new P_Inverse(subPath); return result; } }
public static int countReverseLinks(Iterable<? extends Path> paths) { int result = (int)Streams.stream(paths) .filter(p -> p instanceof P_Path0 ? !((P_Path0)p).isForward() : false) .count(); return result; }
Property p = ResourceFactory.createProperty(path.getNode().getURI());
public static int countForwardLinks(Iterable<? extends Path> paths) { int result = (int)Streams.stream(paths) .filter(p -> p instanceof P_Path0 ? ((P_Path0)p).isForward() : false) .count(); return result; }
if ( p.isForward() ) forwards.add(p) ; else
public static PredicateClass toPredicateClass(P_Path0 path) { ValueSet<Node> f; ValueSet<Node> b; if(path.isForward()) { f = ValueSet.create(true, path.getNode()); b = ValueSet.create(true); } else { f = ValueSet.create(true); b = ValueSet.create(true, path.getNode()); } PredicateClass result = new PredicateClass(f, b); return result; }
public static List<Triple> pathToTriples(SimplePath path, Var start, Var end, Generator<Var> generator) { List<Triple> result = new ArrayList<Triple>(); Var a = start; Iterator<P_Path0> it = path.getSteps().iterator(); while(it.hasNext()) { P_Path0 step = it.next(); Var b; if(it.hasNext()) { b = generator.next();//Var.alloc(generator.next()); } else { b = end; } Triple t; if(step.isForward()) { t = new Triple(a, step.getNode(), b); } else { t = new Triple(b, step.getNode(), a); } result.add(t); a = b; } return result; }