java.lang.Object
org.apache.tinkerpop.gremlin.process.traversal.P<V>
All Implemented Interfaces:
Serializable, Cloneable, Predicate<V>
Direct Known Subclasses:
NotP, TextP

public class P<V> extends Object implements Predicate<V>, Serializable, Cloneable
Predefined Predicate values that can be used to define filters to has() and where().
Author:
Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected PBiPredicate<V,V>
     
    protected Collection<V>
     
    protected Map<String,V>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    P(PBiPredicate<V,V> biPredicate, Collection<V> literals, Map<String,V> variables, boolean isCollection)
     
     
    P(PBiPredicate<V,V> biPredicate, List<Traversal.Admin<?,?>> traversalValues)
    Constructs a P with multiple child traversals resolved at runtime against the current traverser.
     
    P(PBiPredicate<V,V> biPredicate, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
     
     
    P(PBiPredicate<V,V> biPredicate, Traversal.Admin<?,?> traversalValue)
    Constructs a P with a child traversal whose result is resolved at runtime against the current traverser.
     
    P(PBiPredicate<V,V> biPredicate, V value)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    P<V>
    and(Predicate<? super V> predicate)
     
    static <V> P<V>
    between(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> first, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> second)
    Determines if a value is within (inclusive) of the range of the two specified values.
    static <V> P<V>
    between(V first, V second)
    Determines if a value is within (inclusive) of the range of the two specified values.
    P<V>
     
    static void
    collectTraversals(P<?> p, List<Traversal.Admin<?,?>> traversals)
    Recursively collects all child traversals from a predicate tree.
    static <V> P<V>
    eq(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    Determines if values are equal.
    static <V> P<V>
    eq(Traversal<?,?> traversalValue)
    Determines if values are equal using a child traversal resolved at runtime.
    static <V> P<V>
    eq(V value)
    Determines if values are equal.
    boolean
    equals(Object other)
     
     
    Gets the child traversals held by this predicate.
    Set<org.apache.tinkerpop.gremlin.process.traversal.step.GValue<?>>
     
    Get the name of the predicate
    Gets the current value to be passed to the predicate for testing.
    static <V> P<V>
    gt(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    Determines if a value is greater than another.
    static <V> P<V>
    gt(Traversal<?,?> traversalValue)
    Determines if a value is greater than another using a child traversal resolved at runtime.
    static <V> P<V>
    gt(V value)
    Determines if a value is greater than another.
    static <V> P<V>
    gte(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    Determines if a value is greater than or equal to another.
    static <V> P<V>
    gte(Traversal<?,?> traversalValue)
    Determines if a value is greater than or equal to another using a child traversal resolved at runtime.
    static <V> P<V>
    gte(V value)
    Determines if a value is greater than or equal to another.
    int
     
    boolean
    Determines if this predicate holds a child traversal whose result is resolved at runtime.
    static <V> P<V>
    inside(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> first, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> second)
    Determines if a value is within (exclusive) the range of the two specified values.
    static <V> P<V>
    inside(V first, V second)
    Determines if a value is within (exclusive) the range of the two specified values.
    boolean
     
    boolean
    Returns true if the most recent call to resolve(Traverser.Admin) produced no results for a scalar predicate, meaning there is no meaningful comparison value.
    static <V> P<V>
    lt(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    Determines if a value is less than another.
    static <V> P<V>
    lt(Traversal<?,?> traversalValue)
    Determines if a value is less than another using a child traversal resolved at runtime.
    static <V> P<V>
    lt(V value)
    Determines if a value is less than another.
    static <V> P<V>
    lte(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    Determines if a value is less than or equal to another.
    static <V> P<V>
    lte(Traversal<?,?> traversalValue)
    Determines if a value is less than or equal to another using a child traversal resolved at runtime.
    static <V> P<V>
    lte(V value)
    Determines if a value is less than or equal to another.
    P<V>
     
    static <V> P<V>
    neq(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    Determines if values are not equal.
    static <V> P<V>
    neq(Traversal<?,?> traversalValue)
    Determines if values are not equal using a child traversal resolved at runtime.
    static <V> P<V>
    neq(V value)
    Determines if values are not equal.
    static <V> P<V>
    not(P<V> predicate)
    The opposite of the specified P.
    P<V>
    or(Predicate<? super V> predicate)
     
    static <V> P<V>
    outside(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> first, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> second)
    Determines if a value is not within (exclusive) of the range of the two specified values.
    static <V> P<V>
    outside(V first, V second)
    Determines if a value is not within (exclusive) of the range of the two specified values.
    void
    resolve(Traverser.Admin<?> traverser)
    Resolves the child traversal(s) against the given traverser, replacing the traversal value with the resolved literal(s) for this test cycle.
    void
    setValue(V value)
     
    static P
    test(PBiPredicate biPredicate, Object value)
    Construct an instance of P from a BiPredicate.
    boolean
    test(V testValue)
     
     
    static <V> P<V>
    typeOf(Class<?> value)
    Sugar method for Java/Groovy embedded cases only, determines if a value is of a type denoted by class.
    static <V> P<V>
    typeOf(String value)
    Determines if a value is of a type denoted by String key of GlobalTypeCache.
    static <V> P<V>
    typeOf(GType value)
    Determines if a value is of a type denoted by GType.
    void
     
    static <V> P<V>
    within(Collection<V> value)
    Determines if a value is within the specified list of values.
    static <V> P<V>
    within(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V>... values)
    Determines if a value is within the specified list of values.
    static <V> P<V>
    within(Traversal<?,?> traversalValue)
    Determines if a value is within the results of a child traversal resolved at runtime.
    static <V> P<V>
    within(Traversal<?,?> first, Traversal<?,?>... more)
    Determines if a value is within the results of child traversals resolved at runtime.
    static <V> P<V>
    within(V... values)
    Determines if a value is within the specified list of values.
    static <V> P<V>
    without(Collection<V> value)
    Determines if a value is not within the specified list of values.
    static <V> P<V>
    without(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V>... values)
    Determines if a value is not within the specified list of values.
    static <V> P<V>
    without(Traversal<?,?> traversalValue)
    Determines if a value is not within the results of a child traversal resolved at runtime.
    static <V> P<V>
    without(Traversal<?,?> first, Traversal<?,?>... more)
    Determines if a value is not within the results of child traversals resolved at runtime.
    static <V> P<V>
    without(V... values)
    Determines if a value is not within the specified list of values.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • P

      public P(PBiPredicate<V,V> biPredicate, V value)
    • P

      public P(PBiPredicate<V,V> biPredicate, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
    • P

      protected P(PBiPredicate<V,V> biPredicate, Collection<V> literals, Map<String,V> variables, boolean isCollection)
    • P

      public P(PBiPredicate<V,V> biPredicate, Traversal.Admin<?,?> traversalValue)
      Constructs a P with a child traversal whose result is resolved at runtime against the current traverser. The literals and variables are left at their defaults and will be populated when resolve(Traverser.Admin) is called.
    • P

      public P(PBiPredicate<V,V> biPredicate, List<Traversal.Admin<?,?>> traversalValues)
      Constructs a P with multiple child traversals resolved at runtime against the current traverser. Only valid for collection predicates (Contains.within, Contains.without). Each traversal contributes its first result only. The literals and variables are left at their defaults and will be populated when resolve(Traverser.Admin) is called.
      Since:
      4.0.0
  • Method Details

    • getBiPredicate

      public PBiPredicate<V,V> getBiPredicate()
    • getPredicateName

      public String getPredicateName()
      Get the name of the predicate
    • getValue

      public V getValue()
      Gets the current value to be passed to the predicate for testing.
    • setValue

      public void setValue(V value)
    • test

      public boolean test(V testValue)
      Specified by:
      test in interface Predicate<V>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • negate

      public P<V> negate()
      Specified by:
      negate in interface Predicate<V>
    • and

      public P<V> and(Predicate<? super V> predicate)
      Specified by:
      and in interface Predicate<V>
    • or

      public P<V> or(Predicate<? super V> predicate)
      Specified by:
      or in interface Predicate<V>
    • clone

      public P<V> clone()
      Overrides:
      clone in class Object
    • isParameterized

      public boolean isParameterized()
    • updateVariable

      public void updateVariable(String name, Object value)
    • getGValues

      public Set<org.apache.tinkerpop.gremlin.process.traversal.step.GValue<?>> getGValues()
    • hasTraversal

      public boolean hasTraversal()
      Determines if this predicate holds a child traversal whose result is resolved at runtime.
    • isResolvedEmpty

      public boolean isResolvedEmpty()
      Returns true if the most recent call to resolve(Traverser.Admin) produced no results for a scalar predicate, meaning there is no meaningful comparison value.
    • getChildTraversals

      public List<Traversal.Admin<?,?>> getChildTraversals()
      Gets the child traversals held by this predicate. Returns null when this predicate uses literal values or variables.
      Since:
      4.0.0
    • resolve

      public void resolve(Traverser.Admin<?> traverser)
      Resolves the child traversal(s) against the given traverser, replacing the traversal value with the resolved literal(s) for this test cycle. If no traversal is present, this method returns immediately.
    • collectTraversals

      public static void collectTraversals(P<?> p, List<Traversal.Admin<?,?>> traversals)
      Recursively collects all child traversals from a predicate tree. Handles ConnectiveP (recurses into children) and NotP (recurses into wrapped predicate).
    • eq

      public static <V> P<V> eq(V value)
      Determines if values are equal.
      Since:
      3.0.0-incubating
    • eq

      public static <V> P<V> eq(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
      Determines if values are equal.
      Since:
      3.8.0
    • eq

      public static <V> P<V> eq(Traversal<?,?> traversalValue)
      Determines if values are equal using a child traversal resolved at runtime.
      Since:
      4.0.0
    • neq

      public static <V> P<V> neq(V value)
      Determines if values are not equal.
      Since:
      3.0.0-incubating
    • neq

      public static <V> P<V> neq(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
      Determines if values are not equal.
      Since:
      3.8.0
    • neq

      public static <V> P<V> neq(Traversal<?,?> traversalValue)
      Determines if values are not equal using a child traversal resolved at runtime.
      Since:
      4.0.0
    • lt

      public static <V> P<V> lt(V value)
      Determines if a value is less than another.
      Since:
      3.0.0-incubating
    • lt

      public static <V> P<V> lt(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
      Determines if a value is less than another.
      Since:
      3.8.0
    • lt

      public static <V> P<V> lt(Traversal<?,?> traversalValue)
      Determines if a value is less than another using a child traversal resolved at runtime.
      Since:
      4.0.0
    • lte

      public static <V> P<V> lte(V value)
      Determines if a value is less than or equal to another.
      Since:
      3.0.0-incubating
    • lte

      public static <V> P<V> lte(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
      Determines if a value is less than or equal to another.
      Since:
      3.8.0
    • lte

      public static <V> P<V> lte(Traversal<?,?> traversalValue)
      Determines if a value is less than or equal to another using a child traversal resolved at runtime.
      Since:
      4.0.0
    • gt

      public static <V> P<V> gt(V value)
      Determines if a value is greater than another.
      Since:
      3.0.0-incubating
    • gt

      public static <V> P<V> gt(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
      Determines if a value is greater than another.
      Since:
      3.8.0
    • gt

      public static <V> P<V> gt(Traversal<?,?> traversalValue)
      Determines if a value is greater than another using a child traversal resolved at runtime.
      Since:
      4.0.0
    • gte

      public static <V> P<V> gte(V value)
      Determines if a value is greater than or equal to another.
      Since:
      3.0.0-incubating
    • gte

      public static <V> P<V> gte(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> value)
      Determines if a value is greater than or equal to another.
      Since:
      3.8.0
    • gte

      public static <V> P<V> gte(Traversal<?,?> traversalValue)
      Determines if a value is greater than or equal to another using a child traversal resolved at runtime.
      Since:
      4.0.0
    • inside

      public static <V> P<V> inside(V first, V second)
      Determines if a value is within (exclusive) the range of the two specified values.
      Since:
      3.0.0-incubating
    • inside

      public static <V> P<V> inside(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> first, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> second)
      Determines if a value is within (exclusive) the range of the two specified values.
      Since:
      3.8.0
    • outside

      public static <V> P<V> outside(V first, V second)
      Determines if a value is not within (exclusive) of the range of the two specified values.
      Since:
      3.0.0-incubating
    • outside

      public static <V> P<V> outside(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> first, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> second)
      Determines if a value is not within (exclusive) of the range of the two specified values.
      Since:
      3.8.0
    • between

      public static <V> P<V> between(V first, V second)
      Determines if a value is within (inclusive) of the range of the two specified values.
      Since:
      3.0.0-incubating
    • between

      public static <V> P<V> between(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> first, org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V> second)
      Determines if a value is within (inclusive) of the range of the two specified values.
      Since:
      3.8.0
    • within

      public static <V> P<V> within(V... values)
      Determines if a value is within the specified list of values. If the array of arguments itself is null then the argument is treated as Object[1] where that single value is null.
      Since:
      3.0.0-incubating
    • within

      public static <V> P<V> within(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V>... values)
      Determines if a value is within the specified list of values. If the array of arguments itself is null then the argument is treated as Object[1] where that single value is null.
      Since:
      3.8.0
    • within

      public static <V> P<V> within(Collection<V> value)
      Determines if a value is within the specified list of values. Calling this with null is the same as calling within(Object[]) using null.
      Since:
      3.0.0-incubating
    • within

      public static <V> P<V> within(Traversal<?,?> traversalValue)
      Determines if a value is within the results of a child traversal resolved at runtime.
      Since:
      4.0.0
    • within

      public static <V> P<V> within(Traversal<?,?> first, Traversal<?,?>... more)
      Determines if a value is within the results of child traversals resolved at runtime. Each traversal is evaluated independently and results are combined into a single collection.
      Since:
      4.0.0
    • without

      public static <V> P<V> without(V... values)
      Determines if a value is not within the specified list of values. If the array of arguments itself is null then the argument is treated as Object[1] where that single value is null.
      Since:
      3.0.0-incubating
    • without

      public static <V> P<V> without(org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V>... values)
      Determines if a value is not within the specified list of values. If the array of arguments itself is null then the argument is treated as Object[1] where that single value is null.
      Since:
      3.8.0
    • without

      public static <V> P<V> without(Collection<V> value)
      Determines if a value is not within the specified list of values. Calling this with null is the same as calling within(Object[]) using null.
      Since:
      3.0.0-incubating
    • without

      public static <V> P<V> without(Traversal<?,?> traversalValue)
      Determines if a value is not within the results of a child traversal resolved at runtime.
      Since:
      4.0.0
    • without

      public static <V> P<V> without(Traversal<?,?> first, Traversal<?,?>... more)
      Determines if a value is not within the results of child traversals resolved at runtime. Each traversal is evaluated independently and results are combined into a single collection.
      Since:
      4.0.0
    • typeOf

      public static <V> P<V> typeOf(GType value)
      Determines if a value is of a type denoted by GType.
      Since:
      3.8.0
    • typeOf

      public static <V> P<V> typeOf(String value)
      Determines if a value is of a type denoted by String key of GlobalTypeCache.
      Since:
      3.8.0
    • typeOf

      public static <V> P<V> typeOf(Class<?> value)
      Sugar method for Java/Groovy embedded cases only, determines if a value is of a type denoted by class.
      Since:
      3.8.0
    • test

      public static P test(PBiPredicate biPredicate, Object value)
      Construct an instance of P from a BiPredicate.
      Since:
      3.0.0-incubating
    • not

      public static <V> P<V> not(P<V> predicate)
      The opposite of the specified P.
      Since:
      3.0.0-incubating