ProductCaseGeneration

trait ProductCaseGeneration[Pipe[_, _], In, Out]
Companion:
object
class Object
trait Matchable
class Any
trait Generators[Pipe, In, Out]
trait PlatformProductCaseGeneration[Pipe, In, Out]
Definitions[Pipe, In, Out] & Generators[Pipe, In, Out]

Type members

Classlikes

Companion:
class
sealed trait OutFieldLogic[OutField] extends Product with Serializable

Value generation strategy for a particular output parameter/setter

Value generation strategy for a particular output parameter/setter

Companion:
object
Companion:
class
sealed trait ProductGeneratorData extends Product with Serializable

Final platform-independent result of matching inputs with outputs using resolved strategies

Final platform-independent result of matching inputs with outputs using resolved strategies

Companion:
object
final case class ProductInData(getters: ListMap[String, Getter[_]])

Stores information how each attribute/getter could be extracted from In value

Stores information how each attribute/getter could be extracted from In value

Companion:
object
Companion:
class
Companion:
class
sealed trait ProductOutData extends Product with Serializable

Stores information how Out value could be constructed from values of constructor parameters/passed to setters

Stores information how Out value could be constructed from values of constructor parameters/passed to setters

Companion:
object

Types

type Constructor = List[List[Expr[Any]]] => Expr[Out]

Should create Out expression from the constructor arguments grouped in parameter lists

Should create Out expression from the constructor arguments grouped in parameter lists

Value members

Abstract methods

Platform-specific way of parsing In data

Platform-specific way of parsing In data

Should:

  • obtain all methods which are Scala's getters (vals, nullary defs)
  • obtain all methods which are Java Bean getters (starting with is- or get-)
  • for each create an InField factory which takes In argument and returns InField expression
  • form obtained collection into ProductInData

Platform-specific way of parsing Out data

Platform-specific way of parsing Out data

Should:

  • verify whether output is a case class, a case object or a Java Bean
  • obtain respectively:
    • a constructor taking all arguments
    • expression containing case object value
    • a default constructor and collection of setters respectively
  • form obtained data into ProductOutData
def generateProductCode(generatorData: ProductGeneratorData): DerivationResult[Expr[Pipe[In, Out]]]

Platform-specific way of generating code from resolved information

Platform-specific way of generating code from resolved information

For case class output should generate code like:

pipeDerivation.lift { (in: In, ctx: pipeDerivation.Context) =>
 pipeDerivation.mergeResult(
    ctx,
   pipeDerivation.mergeResult(
      ctx,
     pipeDerivation.pure(Array[Any](2)),
     pipeDerivation.unlift(fooPipe, in.foo, pipeDerivation.updateContext(ctx, Path.root.field("foo"))),
     { (left, right) =>
       left(0) = right
       left
      }
   ),
   pipeDerivation.unlift(barPipe, in.bar, pipeDerivation.updateContext(ctx, Path.root.field("bar"))),
   { (left, right) =>
     left(1) = right
     new Out(
       foo = left(0).asInstanceOf[Foo2],
       bar = left(1).asInstanceOf[Bar2],
     )
   }
 )
}

For case object output should generate code like:

pipeDerivation.lift { (in: In, ctx: pipeDerivation.Context) =>
 pipeDerivation.pure(CaseObject)
}

For Java Bean should generate code like:

pipeDerivation.lift { (in: In, ctx: pipeDerivation.Context) =>
 pipeDerivation.mergeResult(
   ctx,
   pipeDerivation.mergeResult(
     ctx,
     pipeDerivation.pure {
       val result = new Out()
       result
     },
     pipeDerivation.unlift(fooPipe, in.foo, pipeDerivation.updateContext(ctx, Path.root.field("foo"))),
     { (left, right) =>
       left.setFoo(right)
       left
     }
   ),
   pipeDerivation.unlift(barPipe, in.bar, pipeDerivation.updateContext(ctx, Path.root.field("bar"))),
   { (left, right) =>
     left.setBar(right)
     left
   }
 )
}
def isCaseClass[A : <none>]: Boolean

True iff A is defined as case class, is NOT abstract and has a public constructor

True iff A is defined as case class, is NOT abstract and has a public constructor

def isCaseObject[A : <none>]: Boolean

True iff A is defined as case object, and is public

True iff A is defined as case object, and is public

def isJavaBean[A : <none>]: Boolean

True iff A has a (public) default constructor and at least one (public) method starting with set

True iff A has a (public) default constructor and at least one (public) method starting with set

def isTuple[A : <none>]: Boolean

True iff A is a tuple

True iff A is a tuple

Concrete methods

final def isUsableAsProductOutput: Boolean

Whether Out type could be constructed as "product case"

Whether Out type could be constructed as "product case"