@Target(value={FIELD,TYPE}) @Retention(value=SOURCE) public @interface Setter
Complete documentation is found at the project lombok features page for @Getter and @Setter.
Even though it is not listed, this annotation also has the onParam
and onMethod
parameter. See the full documentation for more details.
Example:
private @Setter int foo;will generate:
public void setFoo(int foo) { this.foo = foo; }
This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have
a Setter
annotation have the annotation.
Modifier and Type | Optional Element and Description |
---|---|
Setter.AnyAnnotation[] |
onMethod
Any annotations listed here are put on the generated method.
|
Setter.AnyAnnotation[] |
onParam
Any annotations listed here are put on the generated method's parameter.
|
AccessLevel |
value
If you want your setter to be non-public, you can specify an alternate access level here.
|
public abstract AccessLevel value
public abstract Setter.AnyAnnotation[] onMethod
@Setter(onMethod=@__({@AnnotationsGoHere}))
@Setter(onMethod_={@AnnotationsGohere})
// note the underscore after onMethod
.public abstract Setter.AnyAnnotation[] onParam
@Setter(onParam=@__({@AnnotationsGoHere}))
@Setter(onParam_={@AnnotationsGohere})
// note the underscore after onParam
.Copyright © 2024. All rights reserved.