Package org.mapstruct
Annotation Type Builder
-
@Retention(CLASS) @Target({}) @Experimental public @interface Builder
Configuration of builders, e.g. the name of the final build method.Example: Using builder
// Mapper @Mapper public interface SimpleBuilderMapper { @Mapping(target = "name", source = "fullName"), @Mapping(target = "job", constant = "programmer"), SimpleImmutablePerson toImmutable(SimpleMutablePerson source); }
// generates @Override public SimpleImmutablePerson toImmutable(SimpleMutablePerson source) { // name method can be changed with parameter
buildMethod()
Builder simpleImmutablePerson = SimpleImmutablePerson.builder(); simpleImmutablePerson.name( source.getFullName() ); simpleImmutablePerson.age( source.getAge() ); simpleImmutablePerson.address( source.getAddress() ); simpleImmutablePerson.job( "programmer" ); // ... }- Since:
- 1.3
- Author:
- Filip Hrisafov
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description String
buildMethod
The name of the build method that needs to be invoked on the builder to create the type to be buildboolean
disableBuilder
Toggling builders on / off.
-
-
-
Element Detail
-
buildMethod
String buildMethod
The name of the build method that needs to be invoked on the builder to create the type to be build- Returns:
- the method that needs to tbe invoked on the builder
- Default:
- "build"
-
-