[ 
https://issues.apache.org/jira/browse/TINKERPOP-1901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16394475#comment-16394475
 ] 

ASF GitHub Bot commented on TINKERPOP-1901:
-------------------------------------------

GitHub user FlorianHockmann opened a pull request:

    https://github.com/apache/tinkerpop/pull/815

    TINKERPOP-1901 Transform enums into classes in Gremlin.Net

    https://issues.apache.org/jira/browse/TINKERPOP-1901
    
    The various Gremlin tokens like `T`, `Order`, and so on are now classes in 
Gremlin.Net so they can implement interfaces which makes them usable in more 
steps.
    
    Using the example from the issue description, the Java step
    ```java
    public default <V> GraphTraversal<S, E> by(final Traversal<?, ?> traversal,
            final Comparator<V> comparator)
    ```
    now has this equivalent in Gremlin.Net:
    ```cs
    public GraphTraversal<S, E> By (ITraversal traversal, IComparator 
comparator)
    ```
    and `Order` implements `IComparator`.
    
    This example already shows that the Gremlin.Net versions of those 
**interfaces aren't generic** which means in practice that they can still be 
used in some places where it shouldn't be possible. Especially `T` implements 
`Function<Element, Object>` in Java, but simply `IFunction` in Gremlin.Net. So 
users can still use `T` for steps that don't take a lambda with an `Element` 
argument. However, this was also possible before as we simply had the `object` 
type in those places before this PR. So I'd say that we tackle that one later.
    
    All tests pass with `docker/build.sh -t -i -d`
    
    VOTE +1

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/tinkerpop TINKERPOP-1901

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/815.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #815
    
----
commit dcf3da3917a9626d432ef26089bb05c6a15158ed
Author: Florian Hockmann <fh@...>
Date:   2018-03-10T18:17:15Z

    TINKERPOP-1901 Transformed Gremlin.Net enums into classes

commit d012171e97d5d87108eef3d0257a8b859f77de04
Author: Florian Hockmann <fh@...>
Date:   2018-03-10T18:21:46Z

    TINKERPOP-1901 Add interfaces for tokens in Gremlin.Net
    
    These interfaces simply represent their Java counterparts which allows
    to use them as arguments in Gremlin steps.

----


> Enable usage of enums in more steps in Gremlin.Net
> --------------------------------------------------
>
>                 Key: TINKERPOP-1901
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1901
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: dotnet
>    Affects Versions: 3.2.7, 3.3.1
>            Reporter: Florian Hockmann
>            Assignee: Florian Hockmann
>            Priority: Minor
>             Fix For: 3.2.8, 3.3.2
>
>
> Java enums can implement interfaces and some Gremlin steps take interfaces as 
> arguments that are implemented by enums like {{T}} or {{P}} in Java. However, 
> C# enums can't have any methods and therefore also not implement interfaces. 
> For this reason, step arguments whose type is one of those interfaces 
> ({{Predicate}}, {{Function}}, ...) currently have the type {{object}} in 
> Gremlin.Net which makes it hard for users to know what kind of values they 
> can use for these arguments.
> This overload of the {{By}} step is a good example for this:
>  * In Gremlin-java:
> {code:java}
> public default <V> GraphTraversal<S, E> by(final Traversal<?, ?> traversal, 
> final Comparator<V> comparator)
> {code}
>  * In Gremlin.Net:
> {code}
> public GraphTraversal<S, E> By (object function, object comparator)
> {code}
> [~jorgebg] [suggested two possible 
> solutions|https://github.com/apache/tinkerpop/pull/792#discussion_r167847541] 
> for this problem:
> {quote} * Use a class for T (not an enum), properties like T.Id could return 
> instances of whatever interface we create for it. Given that java enums 
> functionality is more comprehensive than what C# currently supports, it makes 
> sense to use a class IMO.
>  * Generate the offending traversal methods manually.{quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to