Package: groovy.transform

## [Groovy] Annotation Type RecordType

- groovy.transform.RecordType

- All Implemented Interfaces and Traits:
    Annotation

      @RecordBase
      @RecordOptions
      @TupleConstructor(namedVariant: true, force: true, defaultsMode: DefaultsMode.AUTO)
      @PropertyOptions
      @KnownImmutable
      @POJO
      @CompileStatic
      @AnnotationCollector(mode: AnnotationCollectorMode.PREFER_EXPLICIT_MERGED)
      @Retention(value: RetentionPolicy.RUNTIME)
      @Target(value: [ElementType.TYPE])
      @Incubating
      @interface RecordType

  Meta annotation used when defining record-like classes.

  It allows you to write classes in this shortened form:

       @groovy.transform.RecordType
       class Cyclist {
           String firstName
           String lastName
       }

       def richie = new Cyclist('Richie', 'Porte')
       assert richie.toString() =~ /Cyclist.*firstName.*Richie/

  The `@RecordType` meta-annotation corresponds to adding the following annotations: RecordBase (which internally piggybacks on `@ToString` and `@EqualsAndHashCode`), ImmutableOptions, PropertyOptions, CompileStatic, POJO, TupleConstructor and KnownImmutable. Together these annotations instruct the compiler to execute the necessary transformations to add the necessary getters, constructors, equals, hashCode and other helper methods that are typically written when creating record-like classes with the defined properties.

  A class created in this way has the following characteristics:

  - The class is automatically made final
  - The serialVersionUID is by default 0
  - Properties automatically have private, final backing fields with getters which are the same name as the fields.
  - A map-based constructor is provided which allows you to set properties by name.
  - A tuple-style constructor is provided which allows you to set properties in the same order as they are defined.
  - Default `equals`, `hashCode` and `toString` methods are provided based on the property values.
  Record-like classes are particularly useful for data structures.
  See Also:
    RecordBase
    ImmutableOptions
    PropertyOptions
    TupleConstructor
    KnownImmutable
    CompileStatic
    POJO
  Since:
    4.0.0

- - ### Inherited Methods Summary

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