Package

dev.nigredo

derivation

Permalink

package derivation

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. derivation
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class Def(ident: String, className: String, excludeFields: List[String] = Nil, rename: List[(String, String)] = Nil) extends Product with Serializable

    Permalink

    Derivation configuration

    Derivation configuration

    ident

    used for grouping new derivation if target of annotation has nested case class

    className

    new derivation class name

    excludeFields

    define which fields have to be excluded from new derivation

    rename

    define how to rename fields during derivation

  2. macro class Derive extends Annotation with StaticAnnotation

    Permalink

    Macro creates new structure in companion object for @see dev.nigredo.derivation.Derivation according to configuration.

    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.

    Annotations
    @compileTimeOnly( ... )

Value Members

  1. object Derivation

    Permalink

    Base simple implementation for Derivation.

    Base simple implementation for Derivation. Take derivation name A and case class B and produce derivation A from B

  2. object DerivationImpl

    Permalink
  3. object Derive

    Permalink
  4. object Store

    Permalink

    Store annotation params between macros

  5. final val configClass: String("Def")

    Permalink
  6. final val packageName: String

    Permalink
  7. final val sealedDerivationName: String("SealedDerivation")

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped