Annotation Type Interface


@Target(PACKAGE)
@Retention(RUNTIME)
@Repeatable(Interfaces.class)
public @interface Interface
The 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.
Author:
Mirko Raner
  • Element Details

    • generate

      String generate
      Returns:
      the simple name of the interface to be generated
    • from

      Class<?> from
      Returns:
      the original class (or interface) from which the new interface will be generated
    • extend

      String[] extend
      Returns:
      the (optional, hence possibly empty) list of base interfaces to extend
      Default:
      {}
    • modifiers

      @Deprecated Modifier[] modifiers
      Deprecated.
      use isStatic() and visibility() instead
      Indicates which modifiers a method in the original class must have so that it will be included in the generated interface. By default, this list is empty, i.e. all methods will be included, irrespective of their modifiers. If this list contains more than one element, the modifiers are combined using an and operation; for example, if the list is PUBLIC, 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.
      Returns:
      the method modifiers to be used for filtering
      Default:
      {}
    • map

      Map[] map
      Returns:
      optional type mappings, if any
      Default:
      {}
    • options

      Options options
      Returns:
      additional code generation options for this interface
      Default:
      @pro.projo.interfaces.annotation.Options
    • isStatic

      Ternary isStatic
      Returns:
      indication whether only static (TRUE), only non-static (FALSE), or both static and non-static methods (EITHER) should be included.
      Default:
      EITHER
    • visibility

      Visibility[] visibility
      Returns:
      the visibilities to be included for method generation (for example, 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})
      Default:
      {PACKAGE, PUBLIC, PROTECTED, PRIVATE}