dev.nigredo.derivation
Macro creates new structure in companion object for @see dev.nigredo.derivation.Derivation according to configuration.
@Derive(Def("Bar", "MyNewCaseClass")) case class Foo(value: Int) object Foo { object Bar { case class MyNewCaseClass(value: Int) } } @Derive(Def("Bar", "MyNewCaseClass", List("value")) case class Foo(value: Int, value2: String) object Foo { object Bar { case class MyNewCaseClass(value2: String) } } @Derive(Def("Bar", "MyNewCaseClass", List("value"), List("value2" -> "renamedValue2")) case class Foo(value: Int, value2: String) object Foo { object Bar { case class MyNewCaseClass(renamedValue2: String) } }
If macro is applied to sealed trait then trait SealedDerivation will be created in companion object as a phantom type.
@Derive("Bar", "MyDerivedClass") sealed trait Foo object Foo { object Bar { sealed trait SealedDerivation } }
Value classes will be simplified during application
case class FooAnyVal(value: String) extends AnyVal @Derive(Def("Bar", "MyNewCaseClass")) case class Foo(value: FooAnyVal) object Foo { object Bar { case class MyNewCaseClass(value: String) } }
Restriction: All data structure has to be define in top level.
derivation config
Macro creates new structure in companion object for @see dev.nigredo.derivation.Derivation according to configuration.
If macro is applied to sealed trait then trait SealedDerivation will be created in companion object as a phantom type.
Value classes will be simplified during application
Restriction: All data structure has to be define in top level.