Class GValue<V>
- 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
AGValueis a variable or literal value that is used in aTraversal. 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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GValue<V>clone()static booleancontainsGValues(Object... args)Tests if any of the objects are GValues.static booleancontainsVariables(Object... args)Tests if any of the objects are GValues or GValueConstantTraversal, and if so, if they are variables.static <T> GValue<T>[]ensureGValues(Object[] args)The elements in object array argument are examined to see if they areGValueobjects.booleanequals(Object o)Vget()Gets the value.static <T> TgetFrom(Object o)If the object is aGValuethen get its value, otherwise return the object as-is.StringgetName()Gets the name of the variable if it was defined as such and returns null if the value was a literal.inthashCode()booleanisNull()Determines if the value held is of anullvalue.booleanisVariable()Determines if the value held by this object was defined as a variable or a literal value.static <V> GValue<V>of(String name, V value)Create a newVarwith the specified name and value.static <V> GValue<V>of(V value)Create a newVarfrom a particular value but without the specified name.static GValue<BigDecimal>ofBigDecimal(String name, BigDecimal value)Create a newGValuefor a BigDecimal value with a specified name.static GValue<BigDecimal>ofBigDecimal(BigDecimal value)Create a newGValuefor a BigDecimal value.static GValue<BigInteger>ofBigInteger(String name, BigInteger value)Create a newGValuefor a BigInteger value with a specified name.static GValue<BigInteger>ofBigInteger(BigInteger value)Create a newGValuefor a BigInteger value.static GValue<Boolean>ofBoolean(Boolean value)Create a newGValuefor a boolean value.static GValue<Boolean>ofBoolean(String name, Boolean value)Create a newGValuefor a boolean value with a specified name.static GValue<Double>ofDouble(Double value)Create a newGValuefor a double value.static GValue<Double>ofDouble(String name, Double value)Create a newGValuefor a double value with a specified name.static GValue<Integer>ofInteger(Integer value)Create a newGValuefor an integer value.static GValue<Integer>ofInteger(String name, Integer value)Create a newGValuefor an integer value with a specified name.static <T> GValue<List<T>>ofList(String name, List<T> value)Create a newGValuefor a list value with a specified name.static <T> GValue<List<T>>ofList(List<T> value)Create a newGValuefor a list value.static GValue<Long>ofLong(Long value)Create a newGValuefor a long value.static GValue<Long>ofLong(String name, Long value)Create a newGValuefor a long value with a specified name.static GValue<Map<?,?>>ofMap(String name, Map value)Create a newGValuefor a map value with a specified name.static GValue<Map>ofMap(Map value)Create a newGValuefor a map value.static GValue<Set>ofSet(String name, Set value)Create a newGValuefor a set value with a specified name.static GValue<Set>ofSet(Set value)Create a newGValuefor a set value.static GValue<String>ofString(String value)Create a newGValuefor a string value.static GValue<String>ofString(String name, String value)Create a newGValuefor a string value with a specified name.static GValue<Vertex>ofVertex(String name, Vertex value)Create a newGValuefor a vertex value with a specified name.static GValue<Vertex>ofVertex(Vertex value)Create a newGValuefor a vertex value.static Object[]resolveToValues(GValue<?>[] gvalues)ConvertsGValueobjects argument array to their values to prevent them from leaking to the Graph API.StringtoString()static booleanvalueInstanceOf(Object o, Class<?> type)static ObjectvalueOf(Object either)Takes an argument that is either aGValueor an object and if the former, returns the child object and if the latter returns the object itself.
-
-
-
Method Detail
-
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 anullvalue.
-
get
public V get()
Gets the value.
-
of
public static <V> GValue<V> of(V value)
Create a newVarfrom a particular value but without the specified name. If the argument provide is already aGValuethen 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 newVarwith the specified name and value. If the argument provide is already aGValuethen an IllegalArgumentException is thrown.- Parameters:
name- the name of the variablevalue- the value of the variable- Throws:
IllegalArgumentException- if value is already aGValue
-
ofString
public static GValue<String> ofString(String value)
Create a newGValuefor a string value.
-
ofString
public static GValue<String> ofString(String name, String value)
Create a newGValuefor a string value with a specified name.
-
ofInteger
public static GValue<Integer> ofInteger(Integer value)
Create a newGValuefor an integer value.
-
ofInteger
public static GValue<Integer> ofInteger(String name, Integer value)
Create a newGValuefor an integer value with a specified name.
-
ofBoolean
public static GValue<Boolean> ofBoolean(Boolean value)
Create a newGValuefor a boolean value.
-
ofBoolean
public static GValue<Boolean> ofBoolean(String name, Boolean value)
Create a newGValuefor a boolean value with a specified name.
-
ofDouble
public static GValue<Double> ofDouble(Double value)
Create a newGValuefor a double value.
-
ofDouble
public static GValue<Double> ofDouble(String name, Double value)
Create a newGValuefor a double value with a specified name.
-
ofBigInteger
public static GValue<BigInteger> ofBigInteger(BigInteger value)
Create a newGValuefor a BigInteger value.
-
ofBigInteger
public static GValue<BigInteger> ofBigInteger(String name, BigInteger value)
Create a newGValuefor a BigInteger value with a specified name.
-
ofBigDecimal
public static GValue<BigDecimal> ofBigDecimal(BigDecimal value)
Create a newGValuefor a BigDecimal value.
-
ofBigDecimal
public static GValue<BigDecimal> ofBigDecimal(String name, BigDecimal value)
Create a newGValuefor a BigDecimal value with a specified name.
-
ofLong
public static GValue<Long> ofLong(String name, Long value)
Create a newGValuefor a long value with a specified name.
-
ofMap
public static GValue<Map<?,?>> ofMap(String name, Map value)
Create a newGValuefor a map value with a specified name.
-
ofList
public static <T> GValue<List<T>> ofList(List<T> value)
Create a newGValuefor a list value.
-
ofList
public static <T> GValue<List<T>> ofList(String name, List<T> value)
Create a newGValuefor a list value with a specified name.
-
ofSet
public static GValue<Set> ofSet(String name, Set value)
Create a newGValuefor a set value with a specified name.
-
ofVertex
public static GValue<Vertex> ofVertex(Vertex value)
Create a newGValuefor a vertex value.
-
ofVertex
public static GValue<Vertex> ofVertex(String name, Vertex value)
Create a newGValuefor a vertex value with a specified name.
-
getFrom
public static <T> T getFrom(Object o)
If the object is aGValuethen get its value, otherwise return the object as-is.
-
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.
-
-