org.apache.tinkerpop.gremlin.process.traversal.util.OrP Java Examples
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.util.OrP.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TraversalUtil.java From hugegraph with Apache License 2.0 | 6 votes |
public static Condition convHas2Condition(HasContainer has, HugeType type, HugeGraph graph) { P<?> p = has.getPredicate(); E.checkArgument(p != null, "The predicate of has(%s) is null", has); BiPredicate<?, ?> bp = p.getBiPredicate(); Condition condition; if (keyForContainsKeyOrValue(has.getKey())) { condition = convContains2Relation(graph, has); } else if (bp instanceof Compare) { condition = convCompare2Relation(graph, type, has); } else if (bp instanceof RelationType) { condition = convRelationType2Relation(graph, type, has); } else if (bp instanceof Contains) { condition = convIn2Relation(graph, type, has); } else if (p instanceof AndP) { condition = convAnd(graph, type, has); } else if (p instanceof OrP) { condition = convOr(graph, type, has); } else { // TODO: deal with other Predicate throw newUnsupportedPredicate(p); } return condition; }
Example #2
Source File: GroovyTranslator.java From tinkerpop with Apache License 2.0 | 6 votes |
protected Script convertPToScript(final P p) { if (p instanceof TextP) { return convertTextPToScript((TextP) p); } if (p instanceof ConnectiveP) { final List<P<?>> list = ((ConnectiveP) p).getPredicates(); for (int i = 0; i < list.size(); i++) { convertPToScript(list.get(i)); if (i < list.size() - 1) { script.append(p instanceof OrP ? ".or(" : ".and("); } } script.append(")"); } else { script.append("P.").append(p.getBiPredicate().toString()).append("("); convertToScript(p.getValue()); script.append(")"); } return script; }
Example #3
Source File: JanusGraphPredicate.java From grakn with GNU Affero General Public License v3.0 | 5 votes |
public static ConnectiveJanusPredicate instanceConnectiveJanusPredicate(P<?> predicate) { final ConnectiveJanusPredicate connectivePredicate; if (predicate.getClass().isAssignableFrom(AndP.class)) { connectivePredicate = new AndJanusPredicate(); } else if (predicate.getClass().isAssignableFrom(OrP.class)) { connectivePredicate = new OrJanusPredicate(); } else { throw new IllegalArgumentException("JanusGraph does not support the given predicate: " + predicate); } return connectivePredicate; }
Example #4
Source File: PTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldComposeCorrectly() { assertEquals(P.eq(1), P.eq(1)); assertEquals(P.eq(1).and(P.eq(2)), new AndP<>(Arrays.asList(P.eq(1), P.eq(2)))); assertEquals(P.eq(1).and(P.eq(2).and(P.eq(3))), new AndP<>(Arrays.asList(P.eq(1), P.eq(2), P.eq(3)))); assertEquals(P.eq(1).and(P.eq(2).and(P.eq(3).and(P.eq(4)))), new AndP<>(Arrays.asList(P.eq(1), P.eq(2), P.eq(3), P.eq(4)))); assertEquals(P.eq(1).or(P.eq(2).or(P.eq(3).or(P.eq(4)))), new OrP<>(Arrays.asList(P.eq(1), P.eq(2), P.eq(3), P.eq(4)))); assertEquals(P.eq(1).or(P.eq(2).and(P.eq(3).or(P.eq(4)))), new OrP<>(Arrays.asList(P.eq(1), new AndP<>(Arrays.asList(P.eq(2), new OrP<>(Arrays.asList(P.eq(3), P.eq(4)))))))); assertEquals(P.eq(1).and(P.eq(2).or(P.eq(3).and(P.eq(4)))), new AndP<>(Arrays.asList(P.eq(1), new OrP<>(Arrays.asList(P.eq(2), new AndP<>(Arrays.asList(P.eq(3), P.eq(4)))))))); assertEquals(P.eq(1).and(P.eq(2).and(P.eq(3).or(P.eq(4)))), new AndP<>(Arrays.asList(P.eq(1), P.eq(2), new OrP<>(Arrays.asList(P.eq(3), P.eq(4)))))); }
Example #5
Source File: P.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public P<V> or(final Predicate<? super V> predicate) { if (!(predicate instanceof P)) throw new IllegalArgumentException("Only P predicates can be or'd together"); return new OrP<>(Arrays.asList(this, (P<V>) predicate)); }
Example #6
Source File: P.java From tinkerpop with Apache License 2.0 | 2 votes |
/** * Determines if a value is not within (exclusive) of the range of the two specified values. * * @since 3.0.0-incubating */ public static <V> P<V> outside(final V first, final V second) { return new OrP<V>(Arrays.asList(new P(Compare.lt, first), new P(Compare.gt, second))); }