@Retention(value=CLASS)
@Target(value=TYPE)
public @interface AutoBuilder
A simple example:
@AutoBuilder(ofClass = Person.class)
abstract class PersonBuilder {
static PersonBuilder builder() {
return new AutoBuilder_PersonBuilder();
}
abstract PersonBuilder setName(String name);
abstract PersonBuilder setId(int id);
abstract Person build();
}| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.String |
callMethod
The static method from
ofClass() to call when the build-method of the builder is called. |
java.lang.Class<?> |
ofClass
The class or interface containing the constructor or static method that the generated builder
will eventually call.
|
public abstract java.lang.String callMethod
ofClass() to call when the build-method of the builder is called.
By default this is empty, meaning that a constructor rather than a static method should be
called. There can be more than one method with the given name, or more than one constructor, in
which case the one to call is the one whose parameter names and types correspond to the
abstract methods of the class or interface with the @AutoBuilder annotation.public abstract java.lang.Class<?> ofClass
@AutoBuilder annotation.Copyright © 2021 Google LLC. All Rights Reserved.