Annotation Type Map


@Target(PACKAGE)
@Retention(RUNTIME)
public @interface Map
The @Map annotation defines a non-default type mapping within an @Interface annotation. By default, in an interface extracted from an existing type, the type occurrence of the existing type will be replaced with the generated interface.
For example, given:
 package existing;
 public class Type
 {
     public static Type self(Type type)
     {
         return type;
     }
 }
 
and
 @Interface(from=existing.Type.class, generate="NewType")
 package generated;
 
the generated interface would look like this:
 public interface NewType
 {
     NewType self(NewType type);
 }
 
In other words, the original interface type is replaced by the generated type in all places where it occurs. Most of the time, this is exactly the desired behavior, but there are some scenarios where a different type needs to be used instead. This occurs, for example, when an existing type declares static and non-static methods that need to be extracted into separate interfaces but need to refer to some common types. The @Map annotation can be used to define these mappings.
Author:
Mirko Raner
  • Required Element Summary

    Required Elements 
    Modifier and Type Required Element Description
    String to  
    Class<?> type  
  • Element Details

    • type

      Class<?> type
      Returns:
      the original type within the context of the enclosing @Interface annotation that is to be mapped.
    • to

      String to
      Returns:
      the generated destination type by which the original type is to be replaced.