[
https://issues.apache.org/jira/browse/TINKERPOP3-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14646417#comment-14646417
]
Matt Frantz commented on TINKERPOP3-787:
----------------------------------------
Another overload would accept a Class object.
{noformat}
<E2 extends List> GraphTraversal<S, E2> withList(Class<? extends List> c);
<E2 extends Map> GraphTraversal<S, E2> withMap(Class<? extends Map> c);
{noformat}
> User-defined containers
> -----------------------
>
> Key: TINKERPOP3-787
> URL: https://issues.apache.org/jira/browse/TINKERPOP3-787
> Project: TinkerPop 3
> Issue Type: Improvement
> Components: process
> 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)