Package org.dellroad.stuff.vaadin7
Class EnumContainer<T extends Enum<T>>
- java.lang.Object
-
- com.vaadin.data.util.AbstractContainer
-
- com.vaadin.data.util.AbstractInMemoryContainer<I,String,BackedItem<T>>
-
- org.dellroad.stuff.vaadin7.AbstractSimpleContainer<I,T>
-
- org.dellroad.stuff.vaadin7.SimpleKeyedContainer<T,T>
-
- org.dellroad.stuff.vaadin7.SelfKeyedContainer<T>
-
- org.dellroad.stuff.vaadin7.EnumContainer<T>
-
- Type Parameters:
T- enum type
- All Implemented Interfaces:
Container,Container.Filterable,Container.Indexed,Container.ItemSetChangeNotifier,Container.Ordered,Container.SimpleFilterable,Container.Sortable,Serializable,Connectable,PropertyExtractor<T>
public class EnumContainer<T extends Enum<T>> extends SelfKeyedContainer<T>
Container backed by the instances of anEnumtype.Instances will auto-detect properties defined by
@ProvidesPropertyannotations (if any), and will also pre-define the following properties:- "name" -
Stringproperty derived fromEnum.name() - "value" - type
Tproperty that returns theEnuminstance value itself - "ordinal" -
Integerproperty derived fromEnum.ordinal() - "toString" -
Stringproperty derived fromEnum.toString()
- See Also:
EnumComboBox, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.data.util.AbstractInMemoryContainer
AbstractInMemoryContainer.BaseItemAddEvent, AbstractInMemoryContainer.BaseItemRemoveEvent
-
Nested classes/interfaces inherited from class com.vaadin.data.util.AbstractContainer
AbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer
-
Nested classes/interfaces inherited from interface com.vaadin.data.Container.Indexed
Container.Indexed.ItemAddEvent, Container.Indexed.ItemRemoveEvent
-
-
Field Summary
Fields Modifier and Type Field Description static StringNAME_PROPERTYstatic StringORDINAL_PROPERTYstatic StringTO_STRING_PROPERTYstatic StringVALUE_PROPERTY
-
Constructor Summary
Constructors Constructor Description EnumContainer(Class<T> type)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<T>getExposedValues(Class<T> type)Get theEnumvalues to expose in this container in the desired order.<V> VgetPropertyValue(T value, PropertyDef<V> propertyDef)Read the value of the property defined bypropertyDeffrom the given object.-
Methods inherited from class org.dellroad.stuff.vaadin7.SelfKeyedContainer
getKeyFor
-
Methods inherited from class org.dellroad.stuff.vaadin7.SimpleKeyedContainer
generateItemId, getItemIdFor, getItemIdForSame, getJavaObject, resetItemIds
-
Methods inherited from class org.dellroad.stuff.vaadin7.AbstractSimpleContainer
addContainerFilter, addContainerFilter, afterReload, connect, createBackedItem, disconnect, getContainerFilters, getContainerProperty, getContainerPropertyIds, getItemIds, getPropertyExtractor, getSortableContainerPropertyIds, getType, getUnfilteredItem, internalRemoveAllItems, load, load, removeAllContainerFilters, removeContainerFilter, removeContainerFilters, setProperties, setProperty, setPropertyExtractor, sort
-
Methods inherited from class com.vaadin.data.util.AbstractInMemoryContainer
addContainerProperty, addFilter, addItem, addItem, addItemAfter, addItemAfter, addItemAt, addItemAt, addItemSetChangeListener, addListener, containsId, doFilterContainer, doSort, filterAll, fireItemAdded, fireItemRemoved, fireItemsAdded, fireItemsRemoved, firstItemId, getAllItemIds, getFilteredItemIds, getFilters, getFirstVisibleItem, getIdByIndex, getItem, getItemIds, getItemSorter, getSortablePropertyIds, getVisibleItemIds, hasContainerFilters, indexOfId, internalAddItemAfter, internalAddItemAt, internalAddItemAtEnd, internalRemoveItem, isFiltered, isFirstId, isLastId, isPropertyFiltered, lastItemId, nextItemId, passesFilters, prevItemId, registerNewItem, removeAllFilters, removeAllItems, removeContainerProperty, removeFilter, removeFilters, removeItem, removeItemSetChangeListener, removeListener, setAllItemIds, setFilteredItemIds, setFilters, setItemSorter, size, sortContainer
-
Methods inherited from class com.vaadin.data.util.AbstractContainer
addListener, addPropertySetChangeListener, fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, removeListener, removePropertySetChangeListener, setItemSetChangeListeners, setPropertySetChangeListeners
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.data.Container
addContainerProperty, addItem, addItem, containsId, getItem, removeAllItems, removeContainerProperty, removeItem, size
-
Methods inherited from interface com.vaadin.data.Container.Ordered
addItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId
-
-
-
-
Field Detail
-
NAME_PROPERTY
public static final String NAME_PROPERTY
- See Also:
- Constant Field Values
-
VALUE_PROPERTY
public static final String VALUE_PROPERTY
- See Also:
- Constant Field Values
-
ORDINAL_PROPERTY
public static final String ORDINAL_PROPERTY
- See Also:
- Constant Field Values
-
TO_STRING_PROPERTY
public static final String TO_STRING_PROPERTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EnumContainer
public EnumContainer(Class<T> type)
Constructor.- Parameters:
type- enum type- Throws:
IllegalArgumentException- iftypeis nullIllegalArgumentException- iftypehas a@ProvidesProperty-annotated method with no property name specified has a name which cannot be interpreted as a bean property "getter" methodIllegalArgumentException- iftypehas two@ProvidesProperty-annotated fields or methods with the same property name
-
-
Method Detail
-
getExposedValues
protected List<T> getExposedValues(Class<T> type)
Get theEnumvalues to expose in this container in the desired order.The implementation in
EnumContainerreturns all values in their natural order. Subclasses may override to filter and/or re-order.- Parameters:
type- enum class instance- Returns:
- instances to include in container
-
getPropertyValue
public <V> V getPropertyValue(T value, PropertyDef<V> propertyDef)
Description copied from class:AbstractSimpleContainerRead the value of the property defined bypropertyDeffrom the given object.The implementation in
AbstractSimpleContainerjust delegates to the configuredPropertyExtractor; subclasses may override to customize property extraction.- Specified by:
getPropertyValuein interfacePropertyExtractor<T extends Enum<T>>- Overrides:
getPropertyValuein classAbstractSimpleContainer<T extends Enum<T>,T extends Enum<T>>- Type Parameters:
V- value type- Parameters:
value- Java objectpropertyDef- definition of which property to read- Returns:
- property value
-
-