@Retention(RUNTIME)
@Inherited
@Target(METHOD)
public @interface Copy
@MyReplacement
meta-annotation defined below as:
@Replace(expression = "`", replacement = "")
@Parsed
public @interface MyReplacement {
@Copy(to = Parsed.class)
String field() default "";
@Copy(to = Parsed.class, property = "index")
int myIndex() default -1;
}
Values set on attributes field
or myIndex
in @MyReplacement
will be assigned to the
attributes field
and index
of the @Parsed
annotation. This allows you to apply the
@MyReplacement
annotation to any given field of your class while configuring the field name and index
to be set for the @Parsed
annotation. This eliminates the need for adding explicit, additional annotations and
their specific property values to each and every field.
The following class can now make use of the @MyReplacement
annotation to apply the the annotations
@Replace
and @Parsed
, configuring the properties of the "inherited" @Parsed
:
public class MyBean {
@MyReplacement
public String id;
@MyReplacementUpperCase(field = "client_name")
public String name;
@MyReplacementUpperCase(myIndex = 4)
public String address;
}
Modifier and Type | Required Element | Description |
---|---|---|
java.lang.Class |
to |
Target annotation class that is part of a meta-annotation.
|
Modifier and Type | Optional Element | Description |
---|---|---|
java.lang.String |
property |
Target property of the given annotation class that is part of a meta-annotation.
|