- All Known Implementing Classes:
RecordBuilderImpl
public sealed interface RecordBuilder<R extends Record> permits RecordBuilderImpl<R>
A builder for record classes.
If any record component is not set to a value during construction,
the value of a given record component is set to its default value.
This is either null for objects or the primitive default value for primitives.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRecordBuilder.ComponentContext<R extends Record,T> -
Method Summary
Modifier and Type Method Description <T extends R>
RecordBlank<T>blank()Creates a new blank for the record class using the previously set record component values.<T extends R>
Tbuild()Creates a new instance of the record class using the previously set record component values.<T> RecordBuilder.ComponentContext<R,T>set(Function<R,T> component)Sets the value for a given record component.<T> RecordBuilder.ComponentContext<R,T>set(LambdaSupport.WrappedFunction<R,T> component)Wrapper overload ofset(Function)
-
Method Details
-
build
Creates a new instance of the record class using the previously set record component values.- Throws:
RecordBuilderException- if any parameter does not have a set value or any error occurs when calling the canonical record constructor
-
blank
Creates a new blank for the record class using the previously set record component values. -
set
Sets the value for a given record component.- Parameters:
component- the record component- Throws:
NullPointerException- if the argument is null
-
set
Wrapper overload ofset(Function)
-