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

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

public class EnumOptionSetDefWithOptionCfg
extends OptionSetDefBase<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.
 
Fields inherited from class org.pm4j.core.pm.impl.options.OptionSetDefBase
getOptionValuesMethod, idPath, nullOption, nullOptionTitleResKey, optionsPath, sortComparatorFactory, titlePath
 
Constructor Summary
EnumOptionSetDefWithOptionCfg(java.lang.Class<?> enumClass, PmOptionCfg optionCfg, java.lang.reflect.Method getOptionValuesMethod)
           
 
Method Summary
 java.lang.String getNullOptionTitle(PmAttrEnumImpl<?> forAttr)
           
protected  java.lang.Iterable<?> getOptionValues(PmAttrEnumImpl<?> forAttr)
          Is only called if no OptionSetDefBase.optionsPath is specified.
protected  PmOption makeOption(PmAttrEnumImpl<?> forAttr, java.lang.Object o)
           
 PmOptionSet makeOptions(PmAttrEnumImpl<?> forAttr)
          Generates the options for the attribute.
 
Methods inherited from class org.pm4j.core.pm.impl.options.OptionSetDefBase
shouldMakeNullOption
 
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

EnumOptionSetDefWithOptionCfg

public EnumOptionSetDefWithOptionCfg(java.lang.Class<?> enumClass,
                                     PmOptionCfg optionCfg,
                                     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<?>>
Overrides:
makeOptions in class OptionSetDefBase<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<?>>
Overrides:
getNullOptionTitle in class OptionSetDefBase<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.

getOptionValues

protected java.lang.Iterable<?> getOptionValues(PmAttrEnumImpl<?> forAttr)
Description copied from class: OptionSetDefBase
Is only called if no OptionSetDefBase.optionsPath is specified.

Overrides:
getOptionValues in class OptionSetDefBase<PmAttrEnumImpl<?>>

makeOption

protected PmOption makeOption(PmAttrEnumImpl<?> forAttr,
                              java.lang.Object o)
Specified by:
makeOption in class OptionSetDefBase<PmAttrEnumImpl<?>>