Object orientation

Seven lessons on classes: the property Groovy writes for a field, the constructors a class gets, the AST transforms that remove the boilerplate of a data class, immutability and records, interfaces and traits, delegation and enums, and the two annotations that hand the checks back to the compiler.

6.1 Classes, properties and fields the property Groovy generates, the field behind it, and the accessors Open 6.2 Constructors and named parameters the map constructor, a declared constructor, and what @CompileStatic changes Open 6.3 The AST transforms of a data class @Canonical, @ToString, @EqualsAndHashCode and @TupleConstructor, with what each one writes Open 6.4 Immutable objects, records and builders @Immutable, a Java record, and @Builder for a long constructor Open 6.5 Interfaces, traits and inheritance an interface, a trait with state, an abstract class, and what each one may hold Open 6.6 @Delegate, enums and visibility delegation instead of inheritance, an enum with fields, and the visibility modifiers Open 6.7 @CompileStatic and @TypeChecked what the compiler catches, what it refuses, and the speed it buys Open

Lessons