lombok-pg -

lombok
Annotation Type AutoGenMethodStub


@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).
 

throwException

public abstract boolean throwException
If you prefer an UnsupportedOperationException being thrown rather than the default value being returned, use @AutoGenMethodStub(throwException = true).

Default:
false

lombok-pg -

Copyright © 2010-2011 Philipp Eichhorn, licensed under the MIT licence.