Annotation Type Wither
Deprecated.
Put on any field to make lombok build a 'wither' - a withX method which produces a clone of this object (except for 1 field which gets a new value).
Complete documentation is found at the project lombok features page for @Wither.
Even though it is not listed, this annotation also has the onParam
and onMethod
parameter. See the full documentation for more details.
Example:
private @Wither 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 Wither
annotation have the annotation.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
Deprecated.Don't use this annotation, ever - Read the documentation. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionDeprecated.Any annotations listed here are put on the generated method.Deprecated.Any annotations listed here are put on the generated method's parameter.Deprecated.If you want your wither to be non-public, you can specify an alternate access level here.
-
Element Details
-
value
AccessLevel valueDeprecated.If you want your wither to be non-public, you can specify an alternate access level here.- Returns:
- The method will be generated with this access modifier.
- Default:
PUBLIC
-
onMethod
Wither.AnyAnnotation[] onMethodDeprecated.Any annotations listed here are put on the generated method. The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
up to JDK7:
@Wither(onMethod=@__({@AnnotationsGoHere}))
from JDK8:
@Wither(onMethod_={@AnnotationsGohere})
// note the underscore afteronMethod
.- Returns:
- List of annotations to apply to the generated method.
- Default:
{}
-
onParam
Wither.AnyAnnotation[] onParamDeprecated.Any annotations listed here are put on the generated method's parameter. The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
up to JDK7:
@Wither(onParam=@__({@AnnotationsGoHere}))
from JDK8:
@Wither(onParam_={@AnnotationsGohere})
// note the underscore afteronParam
.- Returns:
- List of annotations to apply to the generated parameter in the method.
- Default:
{}
-
With
has been promoted to the main package, so use that one instead.