@Retention(value=CLASS)
@Target(value={TYPE,METHOD,CONSTRUCTOR,ANNOTATION_TYPE})
public @interface GeneratePojoBuilder
| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.String |
intoPackage
Specifies the package of the generated builder.
|
java.lang.Class<?> |
withBaseclass
Specifies the base class of the generated builder.
|
java.lang.Class<?> |
withBuilderInterface
Specifies the generic builder interface of the generated builder.
|
boolean |
withBuilderProperties
Specifies whether the generated builder should define builder-based setter-methods using the
builder interface.
|
boolean |
withCopyMethod
Specifies whether a copy method should be generated.
|
java.lang.String |
withFactoryMethod
Specifies the name of a static factory method added to the builder.
|
boolean |
withGenerationGap
Specifies whether the generation gap pattern is used.
|
java.lang.String |
withName
Specifies the name of the generated builder.
|
java.lang.Class<?> |
withOptionalProperties
Specifies whether the generated builder should define optional-based setter-methods using the
specified 'Optional' type.
|
java.lang.String |
withSetterNamePattern
Specifies the name pattern of the generated setter-methods.
|
java.lang.Class<?> |
withValidator
Specifies the validator class that should be used to validate the created pojo.
|
public abstract java.lang.Class<?> withBaseclass
public abstract java.lang.Class<?> withBuilderInterface
build() method having this type as return type.
For example:
public interface Builder<T> {
T build();
}
Void, if no interface is
specifiedpublic abstract boolean withBuilderProperties
When set to true, the withBuilderInterface() must
specify a valid interface.
public abstract java.lang.Class<?> withOptionalProperties
The 'Optional' type can have any name but must be interface-compatible with the following interface:
public interface Optional<T> {
T get();
boolean isPresent();
}
where T is the generic type parameter matching the property's type.
Examples are Google Guava's com.google.common.base.Optional and java.util.Optional introduced with Java 8.
Void if no optional-based setter-methods should be generatedpublic abstract java.lang.String withName
public abstract java.lang.String withSetterNamePattern
public abstract java.lang.String intoPackage
public abstract boolean withGenerationGap
true if the generation gap should be usedpublic abstract boolean withCopyMethod
true if a copy method should be generatedpublic abstract java.lang.String withFactoryMethod
public class MyPojoBuilder {
public static MyPojoBuilder myPojo() {
return new MyPojoBuilder();
}
}
public abstract java.lang.Class<?> withValidator
validate method having one parameter that is compatible with the pojo's
type. If the validation fails, the method must throw some runtime exception (or one of its
subclasses).
This is an example of how a validator could look like:
public class MyPojoValidator {
public void validate(Pojo pojo) {
if ( - check if pojo is invalid -) {
throw new RuntimeException("This pojo is invalid!");
}
}
}
Void, if no validator should be used.