You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Matt Frantz (JIRA)" <ji...@apache.org> on 2015/07/29 18:51:07 UTC

[jira] [Updated] (TINKERPOP3-787) User-defined containers

     [ https://issues.apache.org/jira/browse/TINKERPOP3-787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Frantz updated TINKERPOP3-787:
-----------------------------------
    Description: 
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}


  was:
For any steps that create containers, we could add a modifier step (like {{by}}) that allows specifying a {{Supplier}} of that container.
{noformat}
GraphTraversal<S, E> withList(Supplier<? extends List> s);
GraphTraversal<S, E> withMap(Supplier<? extends Map> 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")
  .<Student>select("name", "schoolAge")
  .withMap{->new Student()}
  .by(values("name")
  .by(out("school").values("age"))
{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)