|
Lombok - v0.11.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
@Target(value=TYPE) @Retention(value=SOURCE) public @interface ExtensionMethod
Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type.
Before:
@ExtensionMethod(java.util.Arrays.class)
class Example {
private void example() {
long[] values = new long[] { 2, 5, 7, 9 };
values.copyOf(3).sort();
}
}
After:
class Example {
private void example() {
long[] values = new long[] { 2, 5, 7, 9 };
java.util.Arrays.sort(java.util.Arrays.copyOf(values, 3));
}
}
| Required Element Summary | |
|---|---|
Class<?>[] |
value
All types whose static methods will be exposed as extension methods. |
| Optional Element Summary | |
|---|---|
boolean |
suppressBaseMethods
If true, an applicable extension method is used (if found) even if the method call already was compilable (this is the default). |
| Element Detail |
|---|
public abstract Class<?>[] value
public abstract boolean suppressBaseMethods
true, an applicable extension method is used (if found) even if the method call already was compilable (this is the default).
If false, an extension method is only used if the method call is not also defined by the type itself.
|
Lombok - v0.11.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||