public class ElementHelper
extends java.lang.Object
Element.| Constructor and Description |
|---|
ElementHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(Element a,
java.lang.Object b)
A standard method for determining if two
Element objects are equal. |
static boolean |
areEqual(Property a,
java.lang.Object b)
A standard method for determining if two
Property objects are equal. |
static boolean |
areEqual(VertexProperty a,
java.lang.Object b)
A standard method for determining if two
VertexProperty objects are equal. |
static java.util.Map<java.lang.String,java.lang.Object> |
asMap(java.lang.Object... keyValues)
Converts a set of key values to a Map.
|
static java.util.List<org.javatuples.Pair<java.lang.String,java.lang.Object>> |
asPairs(java.lang.Object... keyValues)
Convert a set of key values to a list of Pair objects.
|
static void |
attachProperties(Element element,
java.lang.Object... propertyKeyValues)
Assign key/value pairs as properties to an
Element. |
static void |
attachSingleProperties(Vertex vertex,
java.lang.Object... propertyKeyValues)
Assign key/value pairs as properties to an
Vertex. |
static java.util.Optional<java.lang.Object> |
getIdValue(java.lang.Object... keyValues)
Extracts the value of the
T.id key from the list of arguments. |
static java.util.Set<java.lang.String> |
getKeys(java.lang.Object... keyValues)
Gets the list of keys from the key values.
|
static java.util.Optional<java.lang.String> |
getLabelValue(java.lang.Object... keyValues)
Extracts the value of the
T.label key from the list of arguments. |
static Vertex |
getOrAddVertex(Graph graph,
java.lang.Object id,
java.lang.String label)
Check if the vertex, by ID, exists.
|
static java.lang.Object[] |
getProperties(Element element,
boolean includeId,
boolean includeLabel,
java.util.Set<java.lang.String> propertiesToCopy)
Retrieve the properties associated with a particular element.
|
static int |
hashCode(Element element)
If two
Element instances are equal, then they must have the same hash codes. |
static int |
hashCode(Property property)
If two
Property instances are equal, then they must have the same hash codes. |
static boolean |
haveEqualIds(Element a,
Element b)
Simply tests if the value returned from
Element.id() are equal(). |
static boolean |
idExists(java.lang.Object id,
java.lang.Object... providedIds) |
static boolean |
keyExists(java.lang.String key,
java.lang.String... providedKeys) |
static void |
legalPropertyKeyValueArray(java.lang.Object... propertyKeyValues)
Determines whether a list of key/values are legal, ensuring that there are an even number of values submitted
and that the key values in the list of arguments are
String or Element objects. |
static java.util.Map<java.lang.String,Property> |
propertyMap(Element element,
java.lang.String... propertyKeys) |
static java.util.Map<java.lang.String,java.lang.Object> |
propertyValueMap(Element element,
java.lang.String... propertyKeys) |
static java.util.Optional<java.lang.Object[]> |
remove(java.lang.String keyToRemove,
java.lang.Object... keyValues)
Remove a key from the set of key value pairs.
|
static java.util.Optional<java.lang.Object[]> |
remove(T accessor,
java.lang.Object... keyValues) |
static java.lang.Object[] |
upsert(java.lang.Object[] keyValues,
java.lang.String key,
java.lang.Object val)
Append a key/value pair to a list of existing key/values.
|
static void |
validateLabel(java.lang.String label)
Determine whether the Element label can be legally set.
|
static void |
validateProperty(java.lang.String key,
java.lang.Object value)
Determines whether the property key/value for the specified thing can be legally set.
|
static java.util.Map<java.lang.String,java.util.List<VertexProperty>> |
vertexPropertyMap(Vertex vertex,
java.lang.String... propertyKeys) |
static java.util.Map<java.lang.String,java.util.List> |
vertexPropertyValueMap(Vertex vertex,
java.lang.String... propertyKeys) |
public static void validateLabel(java.lang.String label)
throws java.lang.IllegalArgumentException
label - the element labeljava.lang.IllegalArgumentException - whether the label is legal and if not, a clear reason exception is providedpublic static Vertex getOrAddVertex(Graph graph, java.lang.Object id, java.lang.String label)
graph - the graph to check for the existence of the vertexid - the id of the vertex to look forlabel - the label of the vertex to set if the vertex does not existpublic static void validateProperty(java.lang.String key,
java.lang.Object value)
throws java.lang.IllegalArgumentException
key - the key of the propertyvalue - the value of the propertyjava.lang.IllegalArgumentException - whether the key/value pair is legal and if not, a clear reason exception
message is providedpublic static void legalPropertyKeyValueArray(java.lang.Object... propertyKeyValues)
throws java.lang.IllegalArgumentException
String or Element objects.propertyKeyValues - a list of key/value pairsjava.lang.IllegalArgumentException - if something in the pairs is illegalpublic static java.util.Optional<java.lang.Object> getIdValue(java.lang.Object... keyValues)
T.id key from the list of arguments.public static java.util.Optional<java.lang.Object[]> remove(java.lang.String keyToRemove,
java.lang.Object... keyValues)
public static java.util.Optional<java.lang.Object[]> remove(T accessor, java.lang.Object... keyValues)
public static java.lang.Object[] upsert(java.lang.Object[] keyValues,
java.lang.String key,
java.lang.Object val)
public static java.util.Map<java.lang.String,java.lang.Object> asMap(java.lang.Object... keyValues)
public static java.util.List<org.javatuples.Pair<java.lang.String,java.lang.Object>> asPairs(java.lang.Object... keyValues)
public static java.util.Set<java.lang.String> getKeys(java.lang.Object... keyValues)
keyValues - a list of key/values pairspublic static java.util.Optional<java.lang.String> getLabelValue(java.lang.Object... keyValues)
T.label key from the list of arguments.public static void attachProperties(Element element, java.lang.Object... propertyKeyValues)
Element. If the value of T.id or
T.label is in the set of pairs, then they are ignored.element - the graph element to assign the propertyKeyValuespropertyKeyValues - the key/value pairs to assign to the elementjava.lang.ClassCastException - if the value of the key is not a Stringjava.lang.IllegalArgumentException - if the value of element is nullpublic static void attachSingleProperties(Vertex vertex, java.lang.Object... propertyKeyValues)
Vertex. If the value of T.id or
T.label is in the set of pairs, then they are ignored.vertex - the vertex to assign the propertyKeyValuespropertyKeyValues - the key/value pairs to assign to the vertexjava.lang.ClassCastException - if the value of the key is not a Stringjava.lang.IllegalArgumentException - if the value of vertex is nullpublic static java.lang.Object[] getProperties(Element element, boolean includeId, boolean includeLabel, java.util.Set<java.lang.String> propertiesToCopy)
element - the element to retrieve properties fromincludeId - include Element.ID in the key/value listincludeLabel - include Element.LABEL in the key/value listpropertiesToCopy - the properties to include with an empty list meaning copy all propertiespublic static boolean areEqual(Element a, java.lang.Object b)
Element objects are equal. This method should be used by any
Object.equals(Object) implementation to ensure consistent behavior. This method is used for Vertex, Edge, and VertexProperty.public static boolean areEqual(VertexProperty a, java.lang.Object b)
VertexProperty objects are equal. This method should be used by any
Object.equals(Object) implementation to ensure consistent behavior.a - the first VertexPropertyb - the second VertexPropertypublic static boolean haveEqualIds(Element a, Element b)
Element.id() are equal().public static int hashCode(Element element)
Element instances are equal, then they must have the same hash codes. This methods ensures consistent hashCode values.element - the element to get the hashCode forpublic static int hashCode(Property property)
Property instances are equal, then they must have the same hash codes. This methods ensures consistent hashCode values.
For VertexProperty use hashCode(com.tinkerpop.gremlin.structure.Element).property - the property to get the hashCode forpublic static boolean areEqual(Property a, java.lang.Object b)
Property objects are equal. This method should be used by any
Object.equals(Object) implementation to ensure consistent behavior.public static java.util.Map<java.lang.String,java.lang.Object> propertyValueMap(Element element, java.lang.String... propertyKeys)
public static java.util.Map<java.lang.String,Property> propertyMap(Element element, java.lang.String... propertyKeys)
public static java.util.Map<java.lang.String,java.util.List> vertexPropertyValueMap(Vertex vertex, java.lang.String... propertyKeys)
public static java.util.Map<java.lang.String,java.util.List<VertexProperty>> vertexPropertyMap(Vertex vertex, java.lang.String... propertyKeys)
public static boolean keyExists(java.lang.String key,
java.lang.String... providedKeys)
public static boolean idExists(java.lang.Object id,
java.lang.Object... providedIds)
Copyright © 2013-2015 TinkerPop. All Rights Reserved.