return new AndP((List<P>) value); case "or": return new OrP((List<P>) value); case "between": return P.between(((List) value).get(0), ((List) value).get(1));
@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"); else if (predicate instanceof OrP) this.predicates.addAll(((OrP) predicate).getPredicates()); else this.predicates.add((P<V>) predicate); return this; }
public OrP(final List<P<V>> predicates) { super(predicates); for (final P<V> p : predicates) { this.or(p); } this.biPredicate = new OrBiPredicate(this); }
@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)); }
public static Condition convOr(HugeGraph graph, HugeType type, HasContainer has) { P<?> p = has.getPredicate(); assert p instanceof OrP; @SuppressWarnings("unchecked") List<P<Object>> predicates = ((OrP<Object>) p).getPredicates(); if (predicates.size() < 2) { throw newUnsupportedPredicate(p); } Condition cond = null; for (P<Object> predicate : predicates) { HasContainer newHas = new HasContainer(has.getKey(), predicate); Condition newCond = convHas2Condition(newHas, type, graph); if (cond == null) { cond = newCond; } else { cond = Condition.or(newCond, cond); } } return cond; }
public OrP(final List<P<V>> predicates) { super(predicates); for (final P<V> p : predicates) { this.or(p); } this.biPredicate = new OrBiPredicate(this); }
@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)); } }
} else if (hasContainer.getPredicate() instanceof OrP && edgeLabels.isEmpty()) { boolean removeContainer = true; final List<P<?>> orps = ((OrP) hasContainer.getPredicate()).getPredicates(); final List<String> newEdges = new ArrayList<>(); for (int i = 0; i < orps.size(); i++) {
@Override public P<V> negate() { super.negate(); return new OrP<>(this.predicates); }
@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"); else if (predicate instanceof OrP) this.predicates.addAll(((OrP) predicate).getPredicates()); else this.predicates.add((P<V>) predicate); return this; }
/** * 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))); }
private List<HasContainer> optimizeOutside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof OrP) { OrP<?> orP = (OrP) hasContainer.getPredicate(); List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
return predicate.equals("and") ? new AndP((List<P>) value) : new OrP((List<P>) value); else if (value instanceof Collection) { if (predicate.equals("between"))
private List<HasContainer> optimizeOutside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof OrP) { OrP<?> orP = (OrP) hasContainer.getPredicate(); List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
return predicate.equals("and") ? new AndP((List<P>) value) : new OrP((List<P>) value); else if (value instanceof Collection) { if (predicate.equals("between"))
public static Condition convOr(HugeGraph graph, HugeType type, HasContainer has) { P<?> p = has.getPredicate(); assert p instanceof OrP; @SuppressWarnings("unchecked") List<P<Object>> predicates = ((OrP<Object>) p).getPredicates(); if (predicates.size() < 2) { throw newUnsupportedPredicate(p); } Condition cond = null; for (P<Object> predicate : predicates) { HasContainer newHas = new HasContainer(has.getKey(), predicate); Condition newCond = convHas2Condition(newHas, type, graph); if (cond == null) { cond = newCond; } else { cond = Condition.or(newCond, cond); } } return cond; }
return predicate.equals(GraphSONTokens.AND) ? new AndP((List<P>) value) : new OrP((List<P>) value); } else if (predicate.equals(GraphSONTokens.NOT) && value instanceof P) { return P.not((P<?>) value);
public void putKeyValueMap(HasContainer hasContainer, Multimap<String, Object> keyValueMap, SchemaTableTree schemaTableTree) { if (p instanceof OrP) { OrP<?> orP = (OrP<?>) p; Preconditions.checkState(orP.getPredicates().size() == 2, "Only handling OrP with 2 predicates!"); P<?> p1 = orP.getPredicates().get(0); P<?> p2 = orP.getPredicates().get(1); keyValueMap.put(hasContainer.getKey(), p1.getValue()); keyValueMap.put(hasContainer.getKey(), p2.getValue());
return predicate.equals(GraphSONTokens.AND) ? new AndP((List<P>) value) : new OrP((List<P>) value); } else if (predicate.equals(GraphSONTokens.NOT) && value instanceof P) { return P.not((P<?>) value);
} else if (hasContainer.getPredicate() instanceof OrP && edgeLabels.isEmpty()) { boolean removeContainer = true; final List<P<?>> orps = ((OrP) hasContainer.getPredicate()).getPredicates(); final List<String> newEdges = new ArrayList<>(); for (int i = 0; i < orps.size(); i++) {