java.lang.Object
org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V>
All Implemented Interfaces:
Serializable, Cloneable

public class GValue<V> extends Object implements Serializable, Cloneable
A GValue is a variable or literal value that is used in a Traversal. It is composed of a key-value pair where the key is the name given to the variable and the value is the object that the variable resolved to. If the name is not given, the value was provided literally in the traversal. The value of the variable can be any object.
See Also:
  • Method Details

    • isVariable

      public boolean isVariable()
      Determines if the value held by this object was defined as a variable or a literal value. Literal values simply have no name.
    • getName

      public String getName()
      Gets the name of the variable if it was defined as such and returns null if the value was a literal.
    • isNull

      public boolean isNull()
      Determines if the value held is of a null value.
    • get

      public V get()
      Gets the value.
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public GValue<V> clone()
      Overrides:
      clone in class Object
    • of

      public static <V> GValue<V> of(V value)
      Create a new Var from a particular value but without the specified name. If the argument provide is already a GValue then it is returned as-is.
      Parameters:
      value - the value of the variable
    • of

      public static <V> GValue<V> of(String name, V value)
      Create a new Var with the specified name and value. If the argument provide is already a GValue then an IllegalArgumentException is thrown.
      Parameters:
      name - the name of the variable
      value - the value of the variable
      Throws:
      IllegalArgumentException - if value is already a GValue
    • ofString

      public static GValue<String> ofString(String value)
      Create a new GValue for a string value.
    • ofString

      public static GValue<String> ofString(String name, String value)
      Create a new GValue for a string value with a specified name.
    • ofInteger

      public static GValue<Integer> ofInteger(Integer value)
      Create a new GValue for an integer value.
    • ofInteger

      public static GValue<Integer> ofInteger(String name, Integer value)
      Create a new GValue for an integer value with a specified name.
    • ofBoolean

      public static GValue<Boolean> ofBoolean(Boolean value)
      Create a new GValue for a boolean value.
    • ofBoolean

      public static GValue<Boolean> ofBoolean(String name, Boolean value)
      Create a new GValue for a boolean value with a specified name.
    • ofDouble

      public static GValue<Double> ofDouble(Double value)
      Create a new GValue for a double value.
    • ofDouble

      public static GValue<Double> ofDouble(String name, Double value)
      Create a new GValue for a double value with a specified name.
    • ofBigInteger

      public static GValue<BigInteger> ofBigInteger(BigInteger value)
      Create a new GValue for a BigInteger value.
    • ofBigInteger

      public static GValue<BigInteger> ofBigInteger(String name, BigInteger value)
      Create a new GValue for a BigInteger value with a specified name.
    • ofBigDecimal

      public static GValue<BigDecimal> ofBigDecimal(BigDecimal value)
      Create a new GValue for a BigDecimal value.
    • ofBigDecimal

      public static GValue<BigDecimal> ofBigDecimal(String name, BigDecimal value)
      Create a new GValue for a BigDecimal value with a specified name.
    • ofLong

      public static GValue<Long> ofLong(Long value)
      Create a new GValue for a long value.
    • ofLong

      public static GValue<Long> ofLong(String name, Long value)
      Create a new GValue for a long value with a specified name.
    • ofMap

      public static GValue<Map> ofMap(Map value)
      Create a new GValue for a map value.
    • ofMap

      public static GValue<Map<?,?>> ofMap(String name, Map value)
      Create a new GValue for a map value with a specified name.
    • ofList

      public static <T> GValue<List<T>> ofList(List<T> value)
      Create a new GValue for a list value.
    • ofList

      public static <T> GValue<List<T>> ofList(String name, List<T> value)
      Create a new GValue for a list value with a specified name.
    • ofSet

      public static GValue<Set> ofSet(Set value)
      Create a new GValue for a set value.
    • ofSet

      public static GValue<Set> ofSet(String name, Set value)
      Create a new GValue for a set value with a specified name.
    • ofVertex

      public static GValue<Vertex> ofVertex(Vertex value)
      Create a new GValue for a vertex value.
    • ofVertex

      public static GValue<Vertex> ofVertex(String name, Vertex value)
      Create a new GValue for a vertex value with a specified name.
    • getFrom

      public static <T> T getFrom(Object o)
      If the object is a GValue then get its value, otherwise return the object as-is.
    • valueInstanceOf

      public static boolean valueInstanceOf(Object o, Class<?> type)
      Tests if the object is a GValue and if so, checks the type of the value against the provided Class.
    • ensureGValues

      public static <T> GValue<T>[] ensureGValues(Object[] args)
      The elements in object array argument are examined to see if they are GValue objects. If they are, they are preserved as is. If they are not then they are wrapped in a GValue object.
    • resolveToValues

      public static Object[] resolveToValues(GValue<?>[] gvalues)
      Converts GValue objects argument array to their values to prevent them from leaking to the Graph API. Providers extending from this step should use this method to get actual values to prevent any GValue objects from leaking to the Graph API.
    • containsGValues

      public static boolean containsGValues(Object... args)
      Tests if any of the objects are GValues.
    • containsVariables

      public static boolean containsVariables(Object... args)
      Tests if any of the objects are GValues or GValueConstantTraversal, and if so, if they are variables.
    • valueOf

      public static Object valueOf(Object either)
      Takes an argument that is either a GValue or an object and if the former, returns the child object and if the latter returns the object itself.