-
Notifications
You must be signed in to change notification settings - Fork 2
Single record options
You can customize the generation of a single record by using the @AutoRecord.Options annotation next to @AutoRecod
.
This annotation can be used to specify various options that will affect how the record is generated.
Here are options that can be customized:
- withBuilder - enable generation of a builder for the record; see Builders
- memoizedHashCode - enable memoization of the
hashCode()
method; see hashCode memoization - memoizedToString - enable memoization of the
toString()
method; see toString memoization
If you enabled builder generation, you can customize it with @RecordBuilder.Options
annotation.
Please visit the Record Builder documentation for details.
You can attach a custom extensions to the generation process to enable specific features. Please see the Extensions page for details.
Here's an example of how you would customize a record generation to enable builder generation and memoization of the hashCode()
and toString()
methods.
Generated builder will add non-optional setter methods for optional record components.
In addition, LoggingExtension
and IsPersonAdultVerifierExtension
extensions will be used during ht generation process.
@AutoRecord
@AutoRecord.Options(withBuilder = true, memoizedHashCode = true, memoizedToString = true)
@RecordBuilder.Options(addConcreteSettersForOptional = true)
@AutoRecord.Extension(extensionClass = LoggingExtension.class, parameters = "info")
@AutoRecord.Extension(extensionClass = IsPersonAdultVerifierExtension.class)
interface Person {
String name();
}