Annotation Type Encoding.Copy


  • @Target(METHOD)
    @Retention(SOURCE)
    public static @interface Encoding.Copy
    With copy method template. Return type should be the type of implementation field. It can have arbitrary parameters so you can describe update-copy to persistent(structural-sharing-copy) collections. The return value of this method will be then compared (in generated code) to the current field value using == comparison and if found equals (in terms of ==), then this will be returned from generated copy routine to short circuit copyings of the whole object if modification would yield equivalent object. This method would preferably be inlined if one-liner and is not reused in other methods. Naming could be supplied.

    The second use of this annotation is to have it along Encoding.Init annotation on a builder initializer method to stress that this initialized can copy the value as we can get from exposed assessor. In other words, this builder setter annotated @Init @Copy can be used to accept the value returned from getter.