package uk.co.nickthecoder.feather.runtime;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Helps cut down on boilerplate code for immutable classes.
* <p>
* Applicable to fields declared in a class's primary constructor.
* All parameters to the primary constructor must be fields.
* <p>
* This generates a method with the same name as the field, which takes a single argument of the same type
* as the field. The return type is the enclosing class.
* It returns a new instance of the class, with a different value for the field.
* <p>
* For example :
* <pre>
* class Square(
*
* @ Data
* val width : double,
*
* @ Data
* value height : double
*
* ) {
* meth area() = width * height
* }
* </pre>
* The following methods are automatically generated :
* <pre>
* meth width( newWidth : double ) = Square( newWidth, height )
* meth height( newHeight : double ) = Square( width, newHeight )
* </pre>
* So we can easily create a NEW square, from an existing one with one field altered. e.g.
* <pre>
* val mySquare = Square( 10, 10 )
* val myRectangle = mySquare.width( 20 ) // Creates a Square( 20, 10 )
* </pre>
*
*
*/
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Data {
}