com.univocity.parsers.annotations
Annotation Type Copy


@Retention(value=RUNTIME)
@Inherited
@Target(value=METHOD)
public @interface Copy

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;
 }
 
 


Required Element Summary
 Class to
          Target annotation class that is part of a meta-annotation.
 
Optional Element Summary
 String property
          Target property of the given annotation class that is part of a meta-annotation.
 

Element Detail

to

public abstract Class to
Target annotation class that is part of a meta-annotation.

Returns:
the class whose properties will be set from a given attribute of a meta-annotation

property

public abstract String property
Target property of the given annotation class that is part of a meta-annotation.

Returns:
the name of the property in the given annotation class that should receive the value of the meta-annotation property.
Default:
""


Copyright © 2017 uniVocity Software Pty Ltd. All rights reserved.