@Documented @Retention(RetentionPolicy.SOURCE) @Target({ElementType.TYPE}) public @interface ImmutableOptions
Class annotation used to assist in the creation of immutable classes. Defines any known immutable properties (or fields) or known immutable classes.
| Type | Name and Description |
|---|---|
Class[] |
knownImmutableClassesAllows you to provide @Immutable with a list of classes which are deemed immutable. |
String[] |
knownImmutablesAllows you to provide @Immutable with a list of property names which are deemed immutable. |
| Methods inherited from class | Name |
|---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Allows you to provide @Immutable with a list of classes which are deemed immutable. By supplying a class in this list, you are vouching for its immutability and @Immutable will do no further checks. Example:
import groovy.transform.*@Immutable(knownImmutableClasses = [Address]) class Person { String first, last Address address }@TupleConstructorclass Address { final String street }
Allows you to provide @Immutable with a list of property names which are deemed immutable. By supplying a property's name in this list, you are vouching for its immutability and @Immutable will do no further checks. Example:
@groovy.transform.Immutable(knownImmutables = ['address'])
class Person {
String first, last
Address address
}
...
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/groovy/transform/ImmutableOptions.html