Allows copying values of meta-annotation properties into the properties of an annotation that composes it. For example,
consider the
@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;
}