@Retention(value=CLASS) @Target(value={}) @Experimental public @interface Builder
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" );
// ...
}
Modifier and Type | Optional Element and Description |
---|---|
String |
buildMethod
The name of the build method that needs to be invoked on the builder to create the type to be build
|
boolean |
disableBuilder
Toggling builders on / off.
|
public abstract String buildMethod
Copyright © 2012-2021 MapStruct Authors; All rights reserved. Released under the Apache Software License 2.0.