net.sourceforge.pmd.lang.rule.properties

## Class EnumeratedProperty<E>

- java.lang.Object
- - net.sourceforge.pmd.lang.rule.properties.AbstractProperty<T>
  - - net.sourceforge.pmd.lang.rule.properties.AbstractEnumeratedProperty<E,Object>
    - - net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty<E>

Type Parameters:
  `E` -

All Implemented Interfaces:
  Comparable<PropertyDescriptor<?>>, PropertyDescriptor<Object>

    public class EnumeratedProperty<E>
    extends AbstractEnumeratedProperty<E,Object>

Defines a datatype with a set of preset values of any type as held within a pair of maps. While the values are not serialized out, the labels are and serve as keys to obtain the values. The choices() method provides the ordered selections to be used in an editor widget.

Author:
  Brian Remedios

### Field Summary

Fields
`static PropertyDescriptorFactory` `FACTORY`

### Fields inherited from class net.sourceforge.pmd.lang.rule.properties.AbstractEnumeratedProperty

`choices, choicesByLabel, labelsByChoice`

### Constructor Summary

Constructors
Constructor and Description
`EnumeratedProperty(String theName, String theDescription, String[] theLabels, E[] theChoices, int defaultIndex, float theUIOrder)` Constructor for EnumeratedProperty.

### Method Summary

Methods
`String` `asDelimitedString(Object value)` Formats the object onto a string suitable for storage within the property map.
`String` `errorFor(Object value)` Validation function that returns a diagnostic error message for a sample property value.
`Class<Object>` `type()` Denotes the value datatype.
`Object` `valueFrom(String value)` If the property is multi-valued then return the separate values after parsing the propertyString provided.

### Methods inherited from class net.sourceforge.pmd.lang.rule.properties.AbstractEnumeratedProperty

`choiceFrom, choices, defaultAsString, nonLegalValueMsgFor`

### Methods inherited from class net.sourceforge.pmd.lang.rule.properties.AbstractProperty

`addAttributesTo, areEqual, asDelimitedString, asString, attributeValuesById, compareTo, defaultHasNullValue, defaultValue, description, equals, hashCode, isArray, isMultiValue, isRequired, multiValueDelimiter, name, preferredRowCount, propertyErrorFor, toString, typeErrorFor, uiOrder, valueErrorFor, valuesErrorFor`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### FACTORY

    public static final PropertyDescriptorFactory FACTORY

### Constructor Detail

#### EnumeratedProperty

    public EnumeratedProperty(String theName,
                      String theDescription,
                      String[] theLabels,
                      E[] theChoices,
                      int defaultIndex,
                      float theUIOrder)

Constructor for EnumeratedProperty.

Parameters:
  `theName` - String
  `theDescription` - String
  `theLabels` - String[]
  `theChoices` - E[]
  `defaultIndex` - int
  `theUIOrder` - float
Throws:
  `IllegalArgumentException`

### Method Detail

#### type

    public Class<Object> type()

Description copied from interface: `PropertyDescriptor`
Denotes the value datatype.

Returns:
  Class
See Also:
  `PropertyDescriptor.type()`

#### errorFor

    public String errorFor(Object value)

Description copied from class: `AbstractProperty`
Validation function that returns a diagnostic error message for a sample property value. Returns null if the value is acceptable.

Specified by:
  `errorFor` in interface `PropertyDescriptor<Object>`
Overrides:
  `errorFor` in class `AbstractProperty<Object>`
Parameters:
  `value` - Object
Returns:
  String
See Also:
  `PropertyDescriptor.errorFor(Object)`

#### valueFrom

    public Object valueFrom(String value)
                     throws IllegalArgumentException

Description copied from interface: `PropertyDescriptor`
If the property is multi-valued then return the separate values after parsing the propertyString provided. If it isn't a multi-valued property then the value will be returned within an array of size[1].

Parameters:
  `value` - String
Returns:
  Object
Throws:
  `IllegalArgumentException`
See Also:
  `PropertyDescriptor.valueFrom(String)`

#### asDelimitedString

    public String asDelimitedString(Object value)

Description copied from class: `AbstractProperty`
Formats the object onto a string suitable for storage within the property map.

Specified by:
  `asDelimitedString` in interface `PropertyDescriptor<Object>`
Overrides:
  `asDelimitedString` in class `AbstractProperty<Object>`
Parameters:
  `value` - Object
Returns:
  String
See Also:
  `PropertyDescriptor.asDelimitedString(Object)`