org.spicefactory.pimento.type
Class EnumType

java.lang.Object
  extended by org.spicefactory.pimento.type.AbstractPropertyType
      extended by org.spicefactory.pimento.type.EnumType
All Implemented Interfaces:
PropertyType

public class EnumType
extends AbstractPropertyType

Represents an Enum property.

Author:
Jens Halm

Constructor Summary
EnumType(String[] names)
          Creates a new instance.
 
Method Summary
 String[] getNames()
          Returns the names of the enum constants for this property.
 Object getValueForSnapshot(Object entity, Property property, IoContext context, FetchMode fetchMode)
          Reads the specified property from the given entity and returns it in a form suitable for inclusion in an entity snapshot.
 
Methods inherited from class org.spicefactory.pimento.type.AbstractPropertyType
prepareValueFromSnapshot, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumType

public EnumType(String[] names)
Creates a new instance.

Parameters:
names - the names of the enum constants for this property
Method Detail

getNames

public String[] getNames()
Returns the names of the enum constants for this property.

Returns:
the names of the enum constants for this property

getValueForSnapshot

public Object getValueForSnapshot(Object entity,
                                  Property property,
                                  IoContext context,
                                  FetchMode fetchMode)
Description copied from interface: PropertyType
Reads the specified property from the given entity and returns it in a form suitable for inclusion in an entity snapshot. For associations this means that non-null values should be converted to snapshots themselves, using the provided IoContext instance. Simple values could be returned as-is in most cases.

Specified by:
getValueForSnapshot in interface PropertyType
Overrides:
getValueForSnapshot in class AbstractPropertyType
Parameters:
entity - the entity to extract the property value from
property - the property to extract
context - the active IoContext
fetchMode - the fetchMode to use if the property type is an association
Returns:
the current value of the property as a simple value, an entity snapshot or an instance of PropertyState