@Target(value=PACKAGE) @Retention(value=RUNTIME) @Repeatable(value=Interfaces.class) public @interface Interface
Interface annotation captures the necessary information for generating an interface
from an existing class (or existing interface) while filtering for certain modifiers. This also
works for modifiers that are not compatible with interfaces, like e.g. static, which is
useful for extracting factory interfaces and similar patterns. For example, the original class
may have a number of static final methods for creating new objects; in the
generated interface these methods will just appear as regular non-static, non-final methods.| Modifier and Type | Required Element and Description |
|---|---|
Class<?> |
from |
String |
generate |
| Modifier and Type | Optional Element and Description |
|---|---|
String[] |
extend |
Ternary |
isStatic |
Map[] |
map |
Modifier[] |
modifiers
Deprecated.
use
isStatic() and visibility() instead |
Options |
options |
Visibility[] |
visibility |
public abstract String generate
public abstract Class<?> from
public abstract String[] extend
@Deprecated public abstract Modifier[] modifiers
isStatic() and visibility() insteadPUBLIC, FINAL, STATIC then only those methods will be
included that are public and final and static. To realize an or operation,
multiple @Interface annotations need to be used.public abstract Map[] map
public abstract Options options
public abstract Visibility[] visibility
PUBLIC will only include public methods,
{PACKAGE, PROTECTED}
will include protected and default/package visibility methods; there is no
direct way to express "not private", but as every method has to have one of
the four supported visibilities this can easily be expressed by listing all
visibilities that should be included, i.e.
{PUBLIC, PACKAGE, PROTECTED})Copyright © 2022. All rights reserved.