-
Notifications
You must be signed in to change notification settings - Fork 0
/
Derive.java
46 lines (41 loc) · 1.49 KB
/
Derive.java
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
package com.kt.codegen;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Specifies that a new class should be generated, derived off the annotated class. The target class
* name is specified by {@link #name()} and string replacements (plain or regex) are specified by
* {@link #replace()}.
*/
@Repeatable(Derivatives.class)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Derive {
/**
* The target class name (without package prefix) to generate.
*
* @return The target class name (without package prefix) to generate.
*/
String name();
/**
* A list of string replacements (plain or regex) to apply to the source code. These replacements
* specify how the source class should be modified to arrive at the derived target class. For
* example, you may want to generate a derived version of a class that doesn't use {@code double}s
* but {@code float}s instead. Then you could specify the following replacements:
*
* <pre>
* {@code
* replace = {
* @Replace(from = "\\bdouble\\b", to = "float", regex = true),
* @Replace(from = "Double.NaN", to = "Float.NaN"),
* ...
* }
* }
* </pre>
*
* @return A list of string replacements (plain or regex) to apply to the source code..
*/
Replace[] replace();
}