Package: groovy.transform

## [Java] Annotation Type ImmutableBase

- groovy.transform.ImmutableBase

- Class annotation used to assist in the creation of immutable classes. Checks on the validity of an immutable class and makes some preliminary changes to the class. Usually used via the `@Immutable` meta annotation.

  Custom property handling:

  - The `@ImmutableBase` annotation supports customization using `@PropertyOptions` which allows a custom property handler to be defined. This is most typically used behind the scenes by the `@Immutable` meta-annotation but you can also define your own handler. If a custom handler is present, it will determine the code generated for the getters and setters of any property.
  See Also:
    Immutable
    ImmutableOptions
    MapConstructor
    TupleConstructor
    PropertyOptions
  Since:
    2.5.0

- - ### Element Summary

    Optional Element Summary
    Type | Name and Description
    --- | ---
    `boolean` | `copyWith` If `true`, this adds a method `copyWith` which takes a Map of new property values and returns a new instance of the Immutable class with these values set.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Element Detail

    - #### public boolean copyWith

      If `true`, this adds a method `copyWith` which takes a Map of new property values and returns a new instance of the Immutable class with these values set. Example:

           @groovy.transform.Immutable(copyWith = true)
           class Person {
               String first, last
           }

           def tim   = new Person( 'tim', 'yates' )
           def alice = tim.copyWith( first:'alice' )

           assert tim.first   == 'tim'
           assert alice.first == 'alice'

      Unknown keys in the map are ignored, and if the values would not change the object, then the original object is returned. If a method called `copyWith` that takes a single parameter already exists in the class, then this setting is ignored, and no method is generated. @default false