@@ -33,7 +33,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.{Bytecode, Path, Scope, Tr
3333import org .apache .tinkerpop .gremlin .structure .{Direction , T }
3434import shapeless .{:: , HList , HNil }
3535import shapeless .ops .hlist .{IsHCons , Mapper , Prepend , RightFolder , ToTraversable , Tupler }
36+ import shapeless .ops .tuple .{Prepend => TuplePrepend }
3637import shapeless .ops .product .ToHList
38+ import shapeless .syntax .std .tuple ._
3739import scala .concurrent .duration .FiniteDuration
3840import scala .reflect .runtime .{universe => ru }
3941import scala .collection .{immutable , mutable }
@@ -117,8 +119,8 @@ class GremlinScala[End](val traversal: GraphTraversal[_, End]) {
117119 otherProjectKeys : String * ): GremlinScala .Aux [JMap [String , A ], Labels ] =
118120 GremlinScala [JMap [String , A ], Labels ](traversal.project(projectKey, otherProjectKeys : _* ))
119121
120- def project [H <: HList ](
121- builder : ProjectionBuilder [HNil ] ⇒ ProjectionBuilder [H ]): GremlinScala [H ] =
122+ def project [H <: Product ](
123+ builder : ProjectionBuilder [Nil . type ] ⇒ ProjectionBuilder [H ]): GremlinScala [H ] =
122124 builder(ProjectionBuilder ()).build(this )
123125
124126 /** You might think that predicate should be `GremlinScala[End] => GremlinScala[Boolean]`,
@@ -1033,27 +1035,27 @@ class GremlinScala[End](val traversal: GraphTraversal[_, End]) {
10331035
10341036}
10351037
1036- class ProjectionBuilder [H <: HList ] private [gremlin] (
1038+ class ProjectionBuilder [T <: Product ] private [gremlin] (
10371039 labels : Seq [String ],
10381040 addBy : GraphTraversal [_, JMap [String , Any ]] ⇒ GraphTraversal [_, JMap [String , Any ]],
1039- buildResult : JMap [String , Any ] ⇒ H ) {
1041+ buildResult : JMap [String , Any ] ⇒ T ) {
10401042
1041- def apply [U , HR <: HList ](by : By [U ])(
1042- implicit prepend : Prepend .Aux [H , U :: HNil , HR ]): ProjectionBuilder [HR ] = {
1043+ def apply [U , TR <: Product ](by : By [U ])(
1044+ implicit prepend : TuplePrepend .Aux [T , Tuple1 [ U ], TR ]): ProjectionBuilder [TR ] = {
10431045 val label = UUID .randomUUID().toString
1044- new ProjectionBuilder [HR ](labels :+ label,
1046+ new ProjectionBuilder [TR ](labels :+ label,
10451047 addBy.andThen(by.apply),
10461048 map ⇒ buildResult(map) :+ map.get(label).asInstanceOf [U ])
10471049 }
10481050
1049- def and [U , HR <: HList ](by : By [U ])(
1050- implicit prepend : Prepend .Aux [H , U :: HNil , HR ]): ProjectionBuilder [HR ] = apply(by)
1051+ def and [U , TR <: Product ](by : By [U ])
1052+ ( implicit prepend : TuplePrepend .Aux [T , Tuple1 [ U ], TR ]): ProjectionBuilder [TR ] = apply(by)
10511053
1052- private [gremlin] def build (g : GremlinScala [_]): GremlinScala [H ] = {
1054+ private [gremlin] def build (g : GremlinScala [_]): GremlinScala [T ] = {
10531055 GremlinScala (addBy(g.traversal.project(labels.head, labels.tail: _* ))).map(buildResult)
10541056 }
10551057}
10561058
10571059object ProjectionBuilder {
1058- def apply () = new ProjectionBuilder [HNil ](Nil , scala.Predef .identity, _ ⇒ HNil )
1060+ def apply () = new ProjectionBuilder [Nil . type ](Nil , scala.Predef .identity, _ ⇒ Nil )
10591061}
0 commit comments