|
lombok-pg - | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||
@Target(value=TYPE) @Retention(value=SOURCE) public @interface AutoGenMethodStub
With this annotation you can avoid cluttering your code with empty methods that an interface forces you to implement. Just implement the ones you need and lombok will create empty stubs for the rest.
Before:
@AutoGenMethodStub
class Foo extends Bar implements Buzz {
public void a() { // overrides Bar.a()
super.a();
}
public void b() { // overrides Buzz.b()
}
}
After:
class Foo extends Bar implements Buzz {
public void a() { // overrides Bar.a()
super.a();
}
public void b() { // overrides Buzz.b()
}
public int c() { // overrides Buzz.c()
return 0;
}
public String d() { // overrides Buzz.d()
return null;
}
}
If you prefer an UnsupportedOperationException being thrown rather
than the default value being returned, use: @AutoGenMethodStub(throwException = true).
Note: Remember that this annotation is a curve ball, decent interface design comes first. But in some cases it removes massive amounts of boilerplate.
| Optional Element Summary | |
|---|---|
boolean |
throwException
If you prefer an UnsupportedOperationException being thrown
rather than the default value being returned, use @AutoGenMethodStub(throwException = true). |
public abstract boolean throwException
UnsupportedOperationException being thrown
rather than the default value being returned, use @AutoGenMethodStub(throwException = true).
|
lombok-pg - | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||