@Target(value={FIELD,TYPE}) @Retention(value=SOURCE) public @interface With
Complete documentation is found at the project lombok features page for @With.
Example:
private @With final int foo;will generate:
public SELF_TYPE withFoo(int foo) { return this.foo == foo ? this : new SELF_TYPE(otherField1, otherField2, 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 With
annotation have the annotation.
Modifier and Type | Optional Element and Description |
---|---|
With.AnyAnnotation[] |
onMethod
Any annotations listed here are put on the generated method.
|
With.AnyAnnotation[] |
onParam
Any annotations listed here are put on the generated method's parameter.
|
AccessLevel |
value
If you want your with method to be non-public, you can specify an alternate access level here.
|
public abstract AccessLevel value
public abstract With.AnyAnnotation[] onMethod
@With(onMethod=@__({@AnnotationsGoHere}))
@With(onMethod_={@AnnotationsGohere})
// note the underscore after onMethod
.public abstract With.AnyAnnotation[] onParam
@With(onParam=@__({@AnnotationsGoHere}))
@With(onParam_={@AnnotationsGohere})
// note the underscore after onParam
.Copyright © 2024. All rights reserved.