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

Matt Frantz commented on TINKERPOP3-787:
----------------------------------------

Another place to put this would be in {{GraphTraversalSource}}, with the intent 
of affecting all container instantiation (in the data path) for the entire 
traversal.
{code}
public <A extends Map> GraphTraversalSourceStub withMap(Supplier<A> s);
public <A extends Map> GraphTraversalSourceStub withMap(Class<A> c);
public <A extends List> GraphTraversalSourceStub withList(Supplier<A> s);
public <A extends List> GraphTraversalSourceStub withList(Class<A> c);
{code}

> User-defined containers
> -----------------------
>
>                 Key: TINKERPOP3-787
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-787
>             Project: TinkerPop 3
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.0.0-incubating
>            Reporter: Matt Frantz
>            Assignee: Marko A. Rodriguez
>
> For any steps that create containers, we could add a modifier step (like 
> {{by}}) that allows specifying a {{Supplier}} of that container.
> {noformat}
> <E2 extends List> GraphTraversal<S, E2> withList(Supplier<E2> s);
> <E2 extends Map> GraphTraversal<S, E2> withMap(Supplier<E2> s);
> {noformat}
> In addition to providing optimized container implementations, it could 
> provide for application-specific derived container types, e.g. a Map subclass 
> with accessor methods for particular keys.
> {noformat}
> class Student extends HashMap<String, Object> {
>   public String name() { return (String)get("name"); }
>   public int schoolAge() { return (Integer)get("schoolAge"); }
> }
> {noformat}
> This in turn allows stronger type safety for traversals, since you could 
> declare the output of a Map-producing step to be your UDT.
> {noformat}
> g.V().as("name", "schoolAge")
>   .select("name", "schoolAge")
>   .<Student>withMap{->new Student()}
>   .by(values("name")
>   .by(out("school").values("age"))
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to