Class GValue<V>
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.step.GValue<V>
-
- All Implemented Interfaces:
Serializable
public class GValue<V> extends Object implements Serializable
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. TheGValuealso includes theGTypethat describes the type it contains.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.GTypegetType()Gets the type of the value.inthashCode()static booleaninstanceOf(Object o, GType type)Checks the type of the object against the providedGType.static booleaninstanceOfCollection(Object o)static booleaninstanceOfNumber(Object o)Returnstrueif the object is a number or aGValuethat contains a number.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 NumbernumberOf(Object either)Takes an argument that is either aGValueor an object and returns itsNumberform, otherwise throws an exception.static <V> GValue<V>of(String name, V value)Create a newVarwith the specified name and value.static GValue<BigDecimal>ofBigDecimal(String name, BigDecimal value)Create a newGValuefor a BigDecimal value with a specified name.static GValue<BigInteger>ofBigInteger(String name, BigInteger value)Create a newGValuefor a BigInteger value with a specified name.static GValue<Boolean>ofBoolean(String name, Boolean value)Create a newGValuefor a boolean value with a specified name.static GValue<Double>ofDouble(String name, Double value)Create a newGValuefor a double value with a specified name.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 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<Set>ofSet(String name, Set value)Create a newGValuefor a set value with a specified name.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 Object[]resolveToValues(GValue<?>[] gvalues)ConvertsGValueobjects argument array to their values to prevent them from leaking to the Graph API.StringtoString()static booleanvalueInstanceOf(Object o, GType type)static booleanvalueInstanceOfCollection(Object o)Tests if the object is aGValueand if so, checks if the type of the value is a collection.static booleanvalueInstanceOfNumeric(Object o)Tests if the object is aGValueand if so, checks if the type of the value is a numeric.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.
-
getType
public GType getType()
Gets the type of the value. The explicit type could be determined withinstanceofon the value, but this might be helpful for cases where the value was constructed with anullvalue which might just return asObject.
-
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(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 name, String value)
Create a newGValuefor a string value with a specified name.
-
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(String name, Boolean value)
Create a newGValuefor a boolean value with a specified name.
-
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(String name, BigInteger value)
Create a newGValuefor a BigInteger value with a specified name.
-
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(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(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.
-
valueInstanceOfCollection
public static boolean valueInstanceOfCollection(Object o)
Tests if the object is aGValueand if so, checks if the type of the value is a collection.
-
valueInstanceOfNumeric
public static boolean valueInstanceOfNumeric(Object o)
Tests if the object is aGValueand if so, checks if the type of the value is a numeric.
-
instanceOfCollection
public static boolean instanceOfCollection(Object o)
-
instanceOfNumber
public static boolean instanceOfNumber(Object o)
Returnstrueif the object is a number or aGValuethat contains a number.
-
valueOf
public static Object valueOf(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.
-
-