Top Description Methods
com.univocity.parsers.annotations

public @Interface Copy

extends Annotation
Annotations
@Retention:RUNTIME
@Inherited
@Target:METHOD
Imports
java.lang.annotation.*

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

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name of the property in the given annotation class that should receive the value of the meta-annotation property.
property
()

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

public Class<T>

Returns:

the class whose properties will be set from a given attribute of a meta-annotation
to
()

Target annotation class that is part of a meta-annotation.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

propertyback to summary
public String property()

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

Returns:String

the name of the property in the given annotation class that should receive the value of the meta-annotation property.

toback to summary
public Class<T> to()

Target annotation class that is part of a meta-annotation.

Returns:Class<T>

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