Top Description Methods
com.univocity.parsers.annotations

public @Interface EnumOptions

extends Annotation
Annotations
@Retention:RUNTIME
@Inherited
@Target:FIELD, METHOD, ANNOTATION_TYPE
Imports
com.univocity.parsers.common.processor.*, com.univocity.parsers.conversions.*, java.lang.annotation.*

The EnumSelector annotation is meant to be used in conjunction with enumeration attributes.

Values parsed from the input will be matched against one or more properties of the enumeration type. By default, values read from the input will be matched against:

You can also define a customElement() of your enumeration type (an attribute or method), as long as it uniquely identifies each value of your enumeration type.

Use the selectors() option to choose which properties to match the parsed input against, and in what order. You will only need to explicitly add a EnumSelector#CUSTOM_FIELD or EnumSelector#CUSTOM_METHOD to the list of selectors() if your customElement() name could point to both an attribute and a method in your enumeration.

This will assign an EnumConversion to this field.

Commonly used for java beans processed using BeanProcessor and/or BeanWriterProcessor

Author
Univocity Software Pty Ltd - [email protected]
See Also
BeanProcessor, BeanWriterProcessor

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name of a custom element (attribute or method) of the enumeration which will match the parsed input and identify an enumeration's value.
customElement
()

Defines the name of a custom element (attribute or method) of the annotated enumeration.

public EnumSelector[]

Returns:

the sequence of properties of the enumeration type to match against the parsed input.
selectors
()

A list of properties of the enumeration type that will be matched against the parsed input to identify which enum element should be assigned to the annotated field.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

customElementback to summary
public String customElement()

Defines the name of a custom element (attribute or method) of the annotated enumeration. This will be used to match the parsed input and identify an individual value of the enumeration. The attribute value, or object returned from the method, should uniquely identify a value of the enumeration;

You will only need to explicitly add a EnumSelector#CUSTOM_FIELD or EnumSelector#CUSTOM_METHOD to the list of selectors() if your customElement() name could point to both an attribute and a method in your enumeration.

Returns:String

the name of a custom element (attribute or method) of the enumeration which will match the parsed input and identify an enumeration's value.

selectorsback to summary
public EnumSelector[] selectors()

A list of properties of the enumeration type that will be matched against the parsed input to identify which enum element should be assigned to the annotated field. By default, values read from the input will be matched against:

  • Enum#name() - the name of the elements in the enumeration type
  • Enum#ordinal() - the ordinal of the elements in the enumeration type
  • Enum#toString() - the String representation of the elements in the enumeration type
Returns:EnumSelector[]

the sequence of properties of the enumeration type to match against the parsed input.