I - the item ID typeT - the type of the Java objects that back each Item in the containerpublic abstract class SimpleKeyedContainer<I,T> extends AbstractSimpleContainer<I,T>
AbstractSimpleContainer where the item IDs are generated from the items themselves
by the subclass-provided method getKeyFor(T).
Restriction: instances can never contain two objects whose keys are equal (in the sense of Object.equals(java.lang.Object)).
AbstractSimpleContainer,
Serialized FormAbstractInMemoryContainer.BaseItemAddEvent, AbstractInMemoryContainer.BaseItemRemoveEventAbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEventContainer.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.ViewerContainer.Indexed.ItemAddEvent, Container.Indexed.ItemRemoveEvent| Modifier | Constructor and Description |
|---|---|
|
SimpleKeyedContainer()
Constructor.
|
protected |
SimpleKeyedContainer(Class<? super T> type)
Constructor.
|
protected |
SimpleKeyedContainer(Collection<? extends PropertyDef<?>> propertyDefs)
Constructor.
|
|
SimpleKeyedContainer(PropertyExtractor<? super T> propertyExtractor)
Constructor.
|
|
SimpleKeyedContainer(PropertyExtractor<? super T> propertyExtractor,
Collection<? extends PropertyDef<?>> propertyDefs)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected I |
generateItemId(T obj)
Create a new, unique item ID for the given object.
|
I |
getItemIdFor(T obj)
Get the container item ID corresponding to the given underlying Java object which is wrapped by this container.
|
I |
getItemIdForSame(T obj)
Get the container item ID corresponding to the given underlying Java object which is wrapped by this container.
|
T |
getJavaObject(Object itemId)
Get the underlying Java object corresponding to the given item ID.
|
protected abstract I |
getKeyFor(T obj)
Get the key to be used as item ID for the given object.
|
protected void |
resetItemIds()
Subclass hook invoked prior to each reload.
|
addContainerFilter, addContainerFilter, afterReload, connect, createBackedItem, disconnect, getContainerFilters, getContainerProperty, getContainerPropertyIds, getItemIds, getPropertyExtractor, getPropertyValue, getSortableContainerPropertyIds, getType, getUnfilteredItem, internalRemoveAllItems, load, load, removeAllContainerFilters, removeContainerFilter, removeContainerFilters, setProperties, setProperty, setPropertyExtractor, sortaddContainerProperty, 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, sortContaineraddListener, addPropertySetChangeListener, fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, removeListener, removePropertySetChangeListener, setItemSetChangeListeners, setPropertySetChangeListenersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemIdaddContainerProperty, addItem, addItem, containsId, getItem, removeAllItems, removeContainerProperty, removeItem, sizepublic SimpleKeyedContainer()
After using this constructor, subsequent invocations of setPropertyExtractor()
and setProperties() are required to define the properties of this container
and how to extract them.
public SimpleKeyedContainer(PropertyExtractor<? super T> propertyExtractor)
After using this constructor, a subsequent invocation of setProperties() is required
to define the properties of this container.
propertyExtractor - used to extract properties from the underlying Java objects;
may be null but then container is not usable until one is configured via
setPropertyExtractor()protected SimpleKeyedContainer(Collection<? extends PropertyDef<?>> propertyDefs)
After using this constructor, a subsequent invocation of setPropertyExtractor() is required
to define how to extract the properties of this container; alternately, subclasses can override
getPropertyValue().
propertyDefs - container property definitions; null is treated like the empty setpublic SimpleKeyedContainer(PropertyExtractor<? super T> propertyExtractor, Collection<? extends PropertyDef<?>> propertyDefs)
propertyExtractor - used to extract properties from the underlying Java objects;
may be null but then container is not usable until one is configured via
setPropertyExtractor()propertyDefs - container property definitions; null is treated like the empty setprotected SimpleKeyedContainer(Class<? super T> type)
Properties will be determined by the @ProvidesProperty and
@ProvidesPropertySort annotated methods in the given class.
type - class to introspect for annotated methodsIllegalArgumentException - if type is nullIllegalArgumentException - if type has two @ProvidesProperty
or @ProvidesPropertySort annotated methods for the same propertyIllegalArgumentException - if a @ProvidesProperty-annotated method with no
property name specified has a name which cannot be interpreted as a bean
property "getter" methodProvidesProperty,
ProvidesPropertySort,
ProvidesPropertyScannerpublic T getJavaObject(Object itemId)
AbstractSimpleContainergetJavaObject in class AbstractSimpleContainer<I,T>itemId - item IDpublic I getItemIdFor(T obj)
Object.equals().
This method uses an internal hash map for efficiency, and assumes that two underlying container objects that are equal will have the same key.
This method is not used by this class but is defined as a convenience for subclasses.
getItemIdFor in class AbstractSimpleContainer<I,T>obj - underlying container objectobject, or null if object is not found in this containerIllegalArgumentException - if object is nullgetItemIdForSame(T)public I getItemIdForSame(T obj)
Object.equals().
This method uses an internal hash map for efficiency.
This method is not used by this class but is defined as a convenience for subclasses.
getItemIdForSame in class AbstractSimpleContainer<I,T>obj - underlying container objectobject, or null if object is not found in this containerIllegalArgumentException - if object is nullgetItemIdFor(T)protected void resetItemIds()
AbstractSimpleContainerresetItemIds in class AbstractSimpleContainer<I,T>protected final I generateItemId(T obj)
AbstractSimpleContainer
The returned item ID must be unique, i.e., not returned by this method since the most recent invocation of
AbstractSimpleContainer.resetItemIds().
generateItemId in class AbstractSimpleContainer<I,T>obj - underlying container object, never nullprotected abstract I getKeyFor(T obj)
obj - underlying container objectCopyright © 2017. All rights reserved.