Annotation Type ImmutableConstructor


  • @Retention(RUNTIME)
    @Target(CONSTRUCTOR)
    public @interface ImmutableConstructor
    Annotation defining which constructor is to be used to create the object in for code generation of immutable beans.

    The constructor must have the same arguments and types as the properties as exposed by the builder. They must also be in the same order. The constructor is responsible for maintaining the invariants of the class, such as validation.

    For example, a property type of 'ImmutableList<Foo>' will have a builder type of 'List<Foo>', thus the constructor must also use 'List'.

    If no constructor specifies this annotation then a constructor will be generated. In many cases it is easiest to generate the constructor, then move it outside the autogenerated block and annotate it.