[
https://issues.apache.org/jira/browse/TINKERPOP-2234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18030691#comment-18030691
]
ASF GitHub Bot commented on TINKERPOP-2234:
-------------------------------------------
spmallette commented on code in PR #3211:
URL: https://github.com/apache/tinkerpop/pull/3211#discussion_r2440531350
##########
docs/src/reference/gremlin-variants.asciidoc:
##########
@@ -1369,6 +1369,30 @@ java -cp target/run-examples-shaded.jar
examples.BasicGremlin
java -cp target/run-examples-shaded.jar examples.ModernTraversals
----
+[[gremlin-java-differences]]
+=== Differences
+
+Gremlin-Java provides additional syntactic sugar that leverages Java's type
system. Most notably, the `P.typeOf()`
+predicate accepts Java `Class` objects directly, providing a more natural and
type-safe way to perform type checking:
+
+[source,java]
+----
+// Java-specific syntax using Class objects
+g.V().values("age").is(P.typeOf(Integer.class))
+g.V().values("name").is(P.typeOf(String.class))
+g.V().has("weight", P.typeOf(Double.class))
+----
+
+This is equivalent to using `GType` enums, but offers compile-time type
checking and IDE support. Other Gremlin
+language variants must use the canonical `GType` enum approach:
+
+[source,java]
+----
+// Canonical syntax available in all languages
+g.V().values("age").is(P.typeOf(GType.INT))
+g.V().values("name").is(P.typeOf(GType.STRING))
+----
+
Review Comment:
i think it would be good to have some mention of what happens when you go
off the standard `GType` mappings. like what happens if you are in
`TinkerGraph` and store a `java.awt.Color`, will `typeOf(Color.class)` work for
that case?
> Introduce Type Predicate
> ------------------------
>
> Key: TINKERPOP-2234
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2234
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.4.2
> Reporter: Stephen Mallette
> Priority: Major
>
> Provide for a {{typeOf()}} predicate that allows for testing the type of an
> object which would enable neat things like:
> {code}
> g.V().outE().has('weight',gt(0.1)).inV().path().unfold().is(typeOf(VERTEX))
> {code}
> See the linked DISCUSS thread for more information.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)