summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/processor/annotations/Target.java
blob: a809b4c7165fd0b76ed4c36ee8eb3e5fe4965baa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ftbsc.lll.processor.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Marks a method as the target method.
 * The method annotated with this, called "stub" within the documentation, should have the
 * same name and parameters as the method it's supposed to represent.
 * It will be discarded unless the containing class is annotated with {@link Patch}
 * and at least another method within the class is annotated with {@link Injector}.
 * @see Patch
 * @see Injector
 */
@Retention(RetentionPolicy.CLASS)
@Repeatable(Target.List.class)
@java.lang.annotation.Target(ElementType.METHOD)
public @interface Target {

   /**
    * Indicates which of the methods annotated with {@link Find} or {@link Injector}
    * is targeting this stub.
    * @return the name of the element this is supposed to apply to
    * @since 0.5.0
    */
   String of();

   /**
    * @return a name which overrides the name of the annotated one, may be used in
    *              cases such as constructors
    * @since 0.5.0
    */
   String methodName() default "";

   /**
    * When set to false, tells the processor to first try to match a single method by name,
    * and to only check parameters if further clarification is needed.
    * While non-strict mode is more computationally efficient, it's ultimately not
    * relevant, as it only matters at compile time. Do not set this to false unless
    * you know what you're doing.
    * @return whether strict mode is to be used
    * @since 0.3.0
    */
   boolean strict() default true;

   /**
    * When set to true, tells the processor to match the synthetic "bridge" method
    * generated by the compiler to handle type erasure.
    * @return whether the bridge method should be targeted instead of the actual method
    * @since 0.5.2
    */
   boolean bridge() default false;

   /**
    * Used to support {@link Target} as a {@link Repeatable} annotation.
    * @since 0.6.1
    */
   @Retention(RetentionPolicy.CLASS)
   @java.lang.annotation.Target(ElementType.METHOD)
   @interface List {
      /**
       * @return the {@link Injector} annotations, as an array
       */
      Target[] value();
   }
}