Annotation Type Unique


  • @Target({METHOD,FIELD,TYPE})
    @Retention(RUNTIME)
    public @interface Unique
    This annotation, when applied to a member method or field in a mixin, indicates that the member should never overwrite a matching member in the target class. This indicates that the member differs from the normal "overlay-like" behaviour of mixins in general, and should only ever be added to the target. For public fields, the annotation has no effect.

    Typical usage of this annotation would be to decorate a utility method in a mixin, or mark an interface-implementing method which must not overwrite a target if it exists (consider appropriate use of Intrinsic in these situations).

    Because of the mixed usage, this annotation has different implications for methods with differing visibility:

    public methods
    public methods marked with this annotation are discarded if a matching target exists. Unless silent() is set to true, a warning-level message is generated.
    private and protected methods
    non-public methods are renamed if a matching target method is found, this allows utility methods to be safely assigned meaningful names in code, but renamed if a conflict occurs when a mixin is applied.

    Notes

    • To mark all methods in a mixin as unique, apply the annotation to the mixin itself
    • Uniqueness can be defined on a per-interface basis by using an Implements annotation with unique set to true
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean silent
      If this annotation is applied to a public method in a mixin and a conflicting method is found in a target class, then a warning-level message is generated in the log.
    • Element Detail

      • silent

        boolean silent
        If this annotation is applied to a public method in a mixin and a conflicting method is found in a target class, then a warning-level message is generated in the log. To suppress this message, set this value to true.
        Returns:
        true to suppress warning message when a public method is discarded
        Default:
        false