java.lang.Object
org.apache.tinkerpop.gremlin.process.traversal.GremlinLang
All Implemented Interfaces:
Serializable, Cloneable

public class GremlinLang extends Object implements Cloneable, Serializable
This class helps to build a gremlin-lang compatible string representation based on a TraversalSource and then a Traversal.
See Also:
  • Constructor Details

    • GremlinLang

      public GremlinLang()
    • GremlinLang

      public GremlinLang(org.apache.tinkerpop.gremlin.structure.io.pdt.PDTRegistry pdtRegistry)
    • GremlinLang

      public GremlinLang(String sourceName, Object... arguments)
  • Method Details

    • getGremlin

      public String getGremlin()
      Get gremlin-lang compatible representation of Traversal
      Returns:
      gremlin-lang compatible String
    • getGremlin

      public String getGremlin(String g)
      Get gremlin-lang compatible representation of Traversal. "g" is expected for gremlin-lang. "__" can be used for an anonymous GraphTraversal.
      Parameters:
      g - GraphTraversalSource name
      Returns:
      gremlin-lang compatible String
    • getParameters

      public Map<String,Object> getParameters()
      Get parameters used in Traversal.
      Returns:
      parameters Map
    • getUnsupportedType

      public String getUnsupportedType()
      Returns the simple class name of the last type encountered by argAsString() that could not be represented as a gremlin-lang literal. An empty string means all types were supported.
      Returns:
      the simple class name of the unsupported type, or empty string if none
    • containsUnsupportedTypes

      public boolean containsUnsupportedTypes()
      Returns true if argAsString() encountered at least one type that could not be represented as a gremlin-lang literal. In remote mode, the driver should check this before sending the request.

      Note: this only covers types encountered while building the gremlin string. Named GValue parameters store their inner value directly in the parameter map without type-checking via argAsString(), so an unsupported type wrapped in a named GValue will not be detected by this method. Such cases are caught separately by convertParametersToString(Map) when the parameter map is serialized. Unnamed GValue instances (null name) recurse into argAsString() and will set this flag.

      Returns:
      true if unsupported types were encountered in the gremlin string
    • getParametersAsString

      public String getParametersAsString()
      Serializes this instance's parameter map to a gremlin-lang map literal string. Keys are parameter names (identifiers), values are formatted using argAsString().
      Returns:
      a gremlin-lang map literal string, e.g. ["x":1,"y":"stephen"] or [:] for empty
    • convertParametersToString

      public static String convertParametersToString(Map<String,Object> params)
      Converts an arbitrary parameter map to a gremlin-lang map literal string. Keys must be valid identifier strings. Values are formatted as gremlin-lang literals.
      Parameters:
      params - the parameter map to convert
      Returns:
      a gremlin-lang map literal string, e.g. ["x":1,"y":"stephen"] or [:] for empty
    • addSource

      public void addSource(String sourceName, Object... arguments)
      Add a TraversalSource instruction to the GremlinLang.
      Parameters:
      sourceName - the traversal source method name (e.g. withSack())
      arguments - the traversal source method arguments
    • addStep

      public void addStep(String stepName, Object... arguments)
      Add a Traversal instruction to the GremlinLang.
      Parameters:
      stepName - the traversal method name (e.g. out())
      arguments - the traversal method arguments
    • getOptionsStrategies

      public List<org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy> getOptionsStrategies()
      Provides a way to get configuration of a Traversal.
      Returns:
      list of OptionsStrategy
    • setPdtRegistry

      public void setPdtRegistry(org.apache.tinkerpop.gremlin.structure.io.pdt.PDTRegistry pdtRegistry)
      Sets the PDTRegistry used for registry-based dehydration of unknown types.
    • getPdtRegistry

      public org.apache.tinkerpop.gremlin.structure.io.pdt.PDTRegistry getPdtRegistry()
      Gets the PDTRegistry used for registry-based dehydration.
    • isEmpty

      public boolean isEmpty()
    • 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 GremlinLang clone()
      Overrides:
      clone in class Object