java.lang.Object
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex
All Implemented Interfaces:
Element, Host, Vertex

public class TinkerVertex extends TinkerElement implements Vertex
Author:
Marko A. Rodriguez (http://markorodriguez.com)
  • Field Details

    • properties

      protected Map<String,List<VertexProperty>> properties
    • outEdges

      protected Map<String,Set<Edge>> outEdges
    • inEdges

      protected Map<String,Set<Edge>> inEdges
    • outEdgesId

      protected Map<String,Set<Object>> outEdgesId
    • inEdgesId

      protected Map<String,Set<Object>> inEdgesId
    • graph

      protected final AbstractTinkerGraph graph
    • vertexLabels

      protected Set<String> vertexLabels
      Multi-label storage for this vertex. Starts as an immutable set (lightweight) and is upgraded to a mutable ConcurrentHashMap-backed set on first label mutation. Concurrent label mutation on the same vertex from multiple threads is not supported.
  • Constructor Details

    • TinkerVertex

      protected TinkerVertex(Object id, String label, AbstractTinkerGraph graph)
    • TinkerVertex

      protected TinkerVertex(Object id, String label, AbstractTinkerGraph graph, long currentVersion)
    • TinkerVertex

      protected TinkerVertex(Object id, Set<String> labels, AbstractTinkerGraph graph)
      Constructs a TinkerVertex with multiple labels.
    • TinkerVertex

      protected TinkerVertex(Object id, Set<String> labels, AbstractTinkerGraph graph, long currentVersion)
      Canonical constructor. Constructs a TinkerVertex with multiple labels and a specific version (for transactional graphs). Uses a single-switch pattern to handle default label injection per the configured cardinality.
  • Method Details

    • labels

      public Set<String> labels()
      Description copied from interface: Element
      Gets all labels for this element.

      For Vertex: may return zero or more labels (multi-label support). For Edge: returns a singleton set (single label only in TinkerGraph). For VertexProperty: returns a singleton set containing the property key.

      Specified by:
      labels in interface Element
      Returns:
      An unmodifiable Set of labels; may be empty for vertices with no labels
    • label

      @Deprecated public String label()
      Deprecated.
      Description copied from interface: Element
      Gets the label for the graph Element which helps categorize it.
      Specified by:
      label in interface Element
      Overrides:
      label in class TinkerElement
      Returns:
      The label of the element
    • addLabel

      public void addLabel(String label, String... labels)
      Description copied from interface: Element
      Adds one or more labels to this element.
      Specified by:
      addLabel in interface Element
      Parameters:
      label - the first label to add
      labels - additional labels to add
    • dropLabels

      public void dropLabels()
      Description copied from interface: Element
      Removes all labels from this element, triggering the provider's default label behavior.
      Specified by:
      dropLabels in interface Element
    • dropLabel

      public void dropLabel(String label, String... labels)
      Description copied from interface: Element
      Removes specific labels from this element. If this action removes all labels, triggers the provider's default label behavior.
      Specified by:
      dropLabel in interface Element
      Parameters:
      label - the first label to remove
      labels - additional labels to remove
    • clone

      public Object clone()
      Specified by:
      clone in class TinkerElement
    • graph

      public Graph graph()
      Description copied from interface: Element
      Get the graph that this element is within.
      Specified by:
      graph in interface Element
      Returns:
      the graph of this element
    • property

      public <V> VertexProperty<V> property(String key)
      Description copied from interface: Vertex
      Get the VertexProperty for the provided key. If the property does not exist, return VertexProperty.empty(). If there are more than one vertex properties for the provided key, then throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(java.lang.String).
      Specified by:
      property in interface Element
      Specified by:
      property in interface Vertex
      Type Parameters:
      V - the expected type of the vertex property value
      Parameters:
      key - the key of the vertex property to get
      Returns:
      the retrieved vertex property
    • property

      public <V> VertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value, Object... keyValues)
      Description copied from interface: Vertex
      Create a new vertex property. If the cardinality is VertexProperty.Cardinality.single, then set the key to the value. If the cardinality is VertexProperty.Cardinality.list, then add a new value to the key. If the cardinality is VertexProperty.Cardinality.set, then only add a new value if that value doesn't already exist for the key. If the value already exists for the key, add the provided key value vertex property properties to it.
      Specified by:
      property in interface Vertex
      Type Parameters:
      V - the type of the value of the vertex property
      Parameters:
      cardinality - the desired cardinality of the property key
      key - the key of the vertex property
      value - The value of the vertex property
      keyValues - the key/value pairs to turn into vertex property properties
      Returns:
      the newly created vertex property
    • keys

      public Set<String> keys()
      Description copied from interface: Element
      Get the keys of the properties associated with this element. The default implementation iterators the properties and stores the keys into a HashSet.
      Specified by:
      keys in interface Element
      Returns:
      The property key set
    • addEdge

      public Edge addEdge(String label, Vertex vertex, Object... keyValues)
      Description copied from interface: Vertex
      Add an outgoing edge to the vertex with provided label and edge properties as key/value pairs. These key/values must be provided in an even number where the odd numbered arguments are String property keys and the even numbered arguments are the related property values.
      Specified by:
      addEdge in interface Vertex
      Parameters:
      label - The label of the edge
      vertex - The vertex to receive an incoming edge from the current vertex
      keyValues - The key/value pairs to turn into edge properties
      Returns:
      the newly created edge
    • remove

      public void remove()
      Description copied from interface: Element
      Removes the Element from the graph.
      Specified by:
      remove in interface Element
    • toString

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

      public Iterator<Edge> edges(Direction direction, String... edgeLabels)
      Description copied from interface: Vertex
      Gets an Iterator of incident edges.
      Specified by:
      edges in interface Vertex
      Parameters:
      direction - The incident direction of the edges to retrieve off this vertex
      edgeLabels - The labels of the edges to retrieve. If no labels are provided, then get all edges.
      Returns:
      An iterator of edges meeting the provided specification
    • vertices

      public Iterator<Vertex> vertices(Direction direction, String... edgeLabels)
      Description copied from interface: Vertex
      Gets an Iterator of adjacent vertices.
      Specified by:
      vertices in interface Vertex
      Parameters:
      direction - The adjacency direction of the vertices to retrieve off this vertex
      edgeLabels - The labels of the edges associated with the vertices to retrieve. If no labels are provided, then get all edges.
      Returns:
      An iterator of vertices meeting the provided specification
    • createTinkerVertexProperty

      protected <V> TinkerVertexProperty<V> createTinkerVertexProperty(TinkerVertex vertex, String key, V value, Object... propertyKeyValues)
    • createTinkerVertexProperty

      protected <V> TinkerVertexProperty<V> createTinkerVertexProperty(Object id, TinkerVertex vertex, String key, V value, Object... propertyKeyValues)
    • properties

      public <V> Iterator<VertexProperty<V>> properties(String... propertyKeys)
      Description copied from interface: Vertex
      Get an Iterator of properties where the propertyKeys is meant to be a filter on the available keys. If no keys are provide then return all the properties.
      Specified by:
      properties in interface Element
      Specified by:
      properties in interface Vertex