Generators

trait Generators[Pipe[_, _], In, Out] extends ProductCaseGeneration[Pipe, In, Out] with SumCaseGeneration[Pipe, In, Out]
trait SumCaseGeneration[Pipe, In, Out]
trait ProductCaseGeneration[Pipe, In, Out]
class Object
trait Matchable
class Any
Definitions[Pipe, In, Out]

Type members

Inherited classlikes

final case class EnumData[A](elements: List[Case[_ <: A]])

Stores information from what pieces Out is made

Stores information from what pieces Out is made

Inherited from:
SumCaseGeneration
object EnumData
Inherited from:
SumCaseGeneration
final case class EnumGeneratorData(subtypes: ListMap[String, InputSubtype])

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

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

Inherited from:
SumCaseGeneration
Inherited from:
SumCaseGeneration
sealed trait InSubtypeLogic[InSubtype <: In] extends Product with Serializable

Translation strategy for a particular input subtype

Translation strategy for a particular input subtype

Inherited from:
SumCaseGeneration
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

Inherited from:
ProductCaseGeneration
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

Inherited from:
ProductCaseGeneration
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

Inherited from:
ProductCaseGeneration
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

Inherited from:
ProductCaseGeneration

Inherited 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

Inherited from:
ProductCaseGeneration
type InSubtype <: In
Inherited from:
SumCaseGeneration

Value members

Abstract methods

def isSubtype[A : <none>, B : <none>]: Boolean

Check is A <:< B in a platform-independent code

Check is A <:< B in a platform-independent code

def lift[I : <none>, O : <none>](call: <none>[(I, Context) => Result[O]]): Expr[Pipe[I, O]]

Should generate code pipeDerivation.lift { (in, ctx) => ... }

Should generate code pipeDerivation.lift { (in, ctx) => ... }

def mergeResults[A : <none>, B : <none>, C : <none>](context: <none>[Context], ra: <none>[Result[A]], rb: <none>[Result[B]], f: <none>[(A, B) => C]): Expr[Result[C]]

Should generate code pipeDerivation.mergeResults(ctx, ra, rb, (a, b) => ...)

Should generate code pipeDerivation.mergeResults(ctx, ra, rb, (a, b) => ...)

def pureResult[A : <none>](a: <none>[A]): Expr[Result[A]]

Should generate code pipeDerivation.pureResult(a)

Should generate code pipeDerivation.pureResult(a)

def reportDiagnostics[A](result: <none>[A]): Unit

Should use platform-specific way of reporting information from macro on INFO level

Should use platform-specific way of reporting information from macro on INFO level

def reportError(errors: List[<none>]): Nothing

Should use platform-specific way of reporting errors from macro

Should use platform-specific way of reporting errors from macro

def unlift[I : <none>, O : <none>](pipe: <none>[Pipe[I, O]], in: <none>[I], ctx: <none>[Context]): Expr[Result[O]]

Should generate code pipeDerivation.unlift(pipe)(in, ctx)

Should generate code pipeDerivation.unlift(pipe)(in, ctx)

def updateContext(context: <none>[Context], path: <none>[Path]): Expr[Context]

Should generate code pipeDerivation.updateContext(ctx, path)

Should generate code pipeDerivation.updateContext(ctx, path)

Concrete methods

final def deriveConfigured(configurationCode: <none>[PipeDerivationConfig[Pipe, In, Out]]): Expr[Pipe[In, Out]]

Derives using Settings parsed from PipeDerivationConfig[Pipe, In, Out] expression

Derives using Settings parsed from PipeDerivationConfig[Pipe, In, Out] expression

final def deriveDefault: Expr[Pipe[In, Out]]

Derives using default Settings

Derives using default Settings

final def diagnosticsMessage[A](result: <none>[A]): String

Generate message to be displayed by macro on INFO level (if requested by config)

Generate message to be displayed by macro on INFO level (if requested by config)

final def errorMessage(errors: List[<none>]): String

Generates error message to be returned from macro on ERROR level

Generates error message to be returned from macro on ERROR level

Inherited methods

def areSubtypesEqual[A : <none>, B : <none>]: Boolean

Check is A =:= B in a platform-independent code

Check is A =:= B in a platform-independent code

Inherited from:
SumCaseGeneration

Platform-specific way of parsing In data

Platform-specific way of parsing In data

Should:

  • obtain a lift of subtypes OR enumeration values
  • form it into EnumData[In]
Inherited from:
SumCaseGeneration

Platform-specific way of parsing Out data

Platform-specific way of parsing Out data

Should:

  • obtain a lift of subtypes OR enumeration values
  • form it into EnumData[In]
Inherited from:
SumCaseGeneration

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
Inherited from:
ProductCaseGeneration

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
Inherited from:
ProductCaseGeneration
def generateEnumCode(generatorData: EnumGeneratorData): DerivationResult[Expr[Pipe[In, Out]]]

Platform-specific way of generating code from resolved information

Platform-specific way of generating code from resolved information

For subtype input should generate code like:

pipeDerivation.lift { (in: In, ctx: pipeDerivation.Context) =>
 in match {
   case inSubtype: In.Foo => pipeDerivation.unlift(fooPipe, inSubtype, updateContext(ctx, path))
   case inSubtype: In.Bar => pipeDerivation.unlift(barPipe, inSubtype, updateContext(ctx, path))
 }
}
Inherited from:
SumCaseGeneration
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
   }
 )
}
Inherited from:
ProductCaseGeneration
def isADT[A : <none>]: Boolean

True iff A is sealed

True iff A is sealed

Inherited from:
SumCaseGeneration
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

Inherited from:
ProductCaseGeneration
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

Inherited from:
ProductCaseGeneration
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

Inherited from:
ProductCaseGeneration
final def isSumType[A : <none>]: Boolean
Inherited from:
SumCaseGeneration
def isTuple[A : <none>]: Boolean

True iff A is a tuple

True iff A is a tuple

Inherited from:
ProductCaseGeneration
final def isUsableAsProductOutput: Boolean

Whether Out type could be constructed as "product case"

Whether Out type could be constructed as "product case"

Inherited from:
ProductCaseGeneration
final def isUsableAsSumTypeConversion: Boolean

Whether both In and Out are ADTs/Java Enums

Whether both In and Out are ADTs/Java Enums

Inherited from:
SumCaseGeneration

Concrete fields

final val resolveConversion: <none> => <none>[<none>[Pipe[In, Out]]]

Takes Settings and passes them to generators, the first which decides it's their case, attempt generation

Takes Settings and passes them to generators, the first which decides it's their case, attempt generation