org.pm4j.core.pm.impl.options
Class EnumOptionSetDef

java.lang.Object
  extended by org.pm4j.core.pm.impl.options.EnumOptionSetDef
All Implemented Interfaces:
PmOptionSetDef<PmAttrEnumImpl<?>>

public class EnumOptionSetDef
extends java.lang.Object
implements PmOptionSetDef<PmAttrEnumImpl<?>>

Provides all items of an enum definition as options.

The provided option titles are based on string resource definitions.

Resource definition sample for an enum type, defined in an own .java-file:

  myEnum.VALUE_ONE       = One
  myEnum.VALUE_TWO       = Two
  myEnum_nullOptionTitle = Please select 'One' or 'Two'.
 
Resource definition sample for an enum type, defined within another type:
  myClass.MyEnum.VALUE_ONE       = One
  myClass.MyEnum.VALUE_TWO       = Two
  myClass.MyEnum_nullOptionTitle = Please select 'One' or 'Two'.
 
The definition of a 'nullOptionTitle' is optional. If omitted, the (optional) default resource key PmOptionCfg.NULL_OPTION_DEFAULT_RESKEY will be used.

Author:
olaf boede

Field Summary
static java.lang.String NULL_OPTION_RESKEY_POSTFIX
          This postfix may be used to define a null option title for a specific enum type.
 
Constructor Summary
EnumOptionSetDef(java.lang.Class<?> enumClass, java.lang.reflect.Method getOptionValuesMethod)
           
 
Method Summary
 java.lang.String getNullOptionTitle(PmAttrEnumImpl<?> forAttr)
           
 PmOptionSet makeOptions(PmAttrEnumImpl<?> forAttr)
          Generates the options for the attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_OPTION_RESKEY_POSTFIX

public static final java.lang.String NULL_OPTION_RESKEY_POSTFIX
This postfix may be used to define a null option title for a specific enum type.

See Also:
Constant Field Values
Constructor Detail

EnumOptionSetDef

public EnumOptionSetDef(java.lang.Class<?> enumClass,
                        java.lang.reflect.Method getOptionValuesMethod)
Method Detail

makeOptions

public PmOptionSet makeOptions(PmAttrEnumImpl<?> forAttr)
Description copied from interface: PmOptionSetDef
Generates the options for the attribute.

Specified by:
makeOptions in interface PmOptionSetDef<PmAttrEnumImpl<?>>
Parameters:
forAttr - The attribute to generate the options for.
Returns:
The options or null when the attribute does not support options at all.

getNullOptionTitle

public java.lang.String getNullOptionTitle(PmAttrEnumImpl<?> forAttr)
Specified by:
getNullOptionTitle in interface PmOptionSetDef<PmAttrEnumImpl<?>>
Parameters:
forAttr - The attribute to generate the null-option title for.
Returns:
The title to display for the option that represents the null selection.