BEANTYPE
- The type of the Beanpublic class BeanItemContainer<BEANTYPE> extends AbstractBeanContainer<BEANTYPE,BEANTYPE>
The properties of the container are determined automatically by introspecting the used JavaBean class. Only beans of the same type can be added to the container.
BeanItemContainer uses the beans themselves as identifiers. The
Object.hashCode()
of a bean is used when storing and looking up beans
so it must not change during the lifetime of the bean (it should not depend
on any part of the bean that can be modified). Typically this restricts the
implementation of Object.equals(Object)
as well in order for it to
fulfill the contract between equals()
and hashCode()
.
To add items to the container, use the methods addBean(Object)
,
AbstractBeanContainer.addBeanAfter(Object, Object)
and AbstractBeanContainer.addBeanAt(int, Object)
.
Also addItem(Object)
, addItemAfter(Object, Object)
and
addItemAt(int, Object)
can be used as synonyms for them.
It is not possible to add additional properties to the container.
AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE>, AbstractBeanContainer.PropertyBasedBeanIdResolver
AbstractInMemoryContainer.BaseItemAddEvent, AbstractInMemoryContainer.BaseItemRemoveEvent
AbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEvent
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
Container.Indexed.ItemAddEvent, Container.Indexed.ItemRemoveEvent
Constructor and Description |
---|
BeanItemContainer(Class<? super BEANTYPE> type)
Constructs a
BeanItemContainer for beans of the given type. |
BeanItemContainer(Class<? super BEANTYPE> type,
Collection<? extends BEANTYPE> collection)
Constructs a
BeanItemContainer and adds the given beans to it. |
BeanItemContainer(Collection<? extends BEANTYPE> collection)
Deprecated.
As of 6.5, use
BeanItemContainer(Class, Collection)
instead |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Collection<? extends BEANTYPE> collection)
Adds all the beans from a
Collection in one go. |
BeanItem<BEANTYPE> |
addBean(BEANTYPE bean)
Adds the bean to the Container.
|
BeanItem<BEANTYPE> |
addItem(Object itemId)
Adds the bean to the Container.
|
BeanItem<BEANTYPE> |
addItemAfter(Object previousItemId,
Object newItemId)
Adds the bean after the given bean.
|
BeanItem<BEANTYPE> |
addItemAt(int index,
Object newItemId)
Adds a new bean at the given index.
|
protected void |
setBeanIdResolver(AbstractBeanContainer.BeanIdResolver<BEANTYPE,BEANTYPE> beanIdResolver)
Unsupported in BeanItemContainer.
|
addBeanAfter, addBeanAt, addContainerFilter, addContainerFilter, addContainerProperty, addContainerProperty, addItem, addItemAfter, addItemAt, addListener, addNestedContainerBean, addNestedContainerProperty, addPropertySetChangeListener, createBeanItem, createBeanPropertyResolver, getBeanIdResolver, getBeanType, getContainerFilters, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getItemSorter, getSortableContainerPropertyIds, getType, getUnfilteredItem, hasContainerFilters, registerNewItem, removeAllContainerFilters, removeAllItems, removeContainerFilter, removeContainerFilters, removeContainerProperty, removeItem, removeListener, removePropertySetChangeListener, resolveBeanId, setItemSorter, sort, valueChange
addFilter, addItem, addItemAfter, addItemAt, addItemSetChangeListener, addListener, containsId, doFilterContainer, doSort, filterAll, fireItemAdded, fireItemRemoved, fireItemsAdded, fireItemsRemoved, firstItemId, getAllItemIds, getFilteredItemIds, getFilters, getFirstVisibleItem, getIdByIndex, getItemIds, getSortablePropertyIds, getVisibleItemIds, indexOfId, internalAddItemAfter, internalAddItemAt, internalAddItemAtEnd, internalRemoveAllItems, internalRemoveItem, isFiltered, isFirstId, isLastId, isPropertyFiltered, lastItemId, nextItemId, passesFilters, prevItemId, removeAllFilters, removeFilter, removeFilters, removeItemSetChangeListener, removeListener, setAllItemIds, setFilteredItemIds, setFilters, size, sortContainer
fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, setItemSetChangeListeners, setPropertySetChangeListeners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId
addItem, containsId, size
public BeanItemContainer(Class<? super BEANTYPE> type) throws IllegalArgumentException
BeanItemContainer
for beans of the given type.type
- the type of the beans that will be added to the container.IllegalArgumentException
- If type
is null@Deprecated public BeanItemContainer(Collection<? extends BEANTYPE> collection) throws IllegalArgumentException
BeanItemContainer(Class, Collection)
insteadBeanItemContainer
and adds the given beans to it.
The collection must not be empty.
BeanItemContainer(Class)
can be used for
creating an initially empty BeanItemContainer
.
Note that when using this constructor, the actual class of the first item
in the collection is used to determine the bean properties supported by
the container instance, and only beans of that class or its subclasses
can be added to the collection. If this is problematic or empty
collections need to be supported, use BeanItemContainer(Class)
and addAll(Collection)
instead.collection
- a non empty Collection
of beans.IllegalArgumentException
- If the collection is null or empty.public BeanItemContainer(Class<? super BEANTYPE> type, Collection<? extends BEANTYPE> collection) throws IllegalArgumentException
BeanItemContainer
and adds the given beans to it.type
- the type of the beans that will be added to the container.collection
- a Collection
of beans (can be empty or null).IllegalArgumentException
- If type
is nullpublic void addAll(Collection<? extends BEANTYPE> collection)
Collection
in one go. More efficient
than adding them one by one.addAll
in class AbstractBeanContainer<BEANTYPE,BEANTYPE>
collection
- The collection of beans to add. Must not be null.public BeanItem<BEANTYPE> addItemAfter(Object previousItemId, Object newItemId) throws IllegalArgumentException
addItemAfter
in interface Container.Ordered
addItemAfter
in class AbstractInMemoryContainer<BEANTYPE,String,BeanItem<BEANTYPE>>
previousItemId
- the bean (of type BT) after which to add newItemIdnewItemId
- the bean (of type BT) to add (not null)IllegalArgumentException
Container.Ordered#addItemAfter(Object, Object)
public BeanItem<BEANTYPE> addItemAt(int index, Object newItemId) throws IllegalArgumentException
addItemAt
in interface Container.Indexed
addItemAt
in class AbstractInMemoryContainer<BEANTYPE,String,BeanItem<BEANTYPE>>
index
- Index at which the bean should be added.newItemId
- The bean to add to the container.IllegalArgumentException
public BeanItem<BEANTYPE> addItem(Object itemId)
addItem
in interface Container
addItem
in class AbstractInMemoryContainer<BEANTYPE,String,BeanItem<BEANTYPE>>
itemId
- ID of the Item to be creatednull
in case of a failureContainer.addItem(Object)
public BeanItem<BEANTYPE> addBean(BEANTYPE bean)
addBean
in class AbstractBeanContainer<BEANTYPE,BEANTYPE>
bean
- the bean to addContainer.addItem(Object)
protected void setBeanIdResolver(AbstractBeanContainer.BeanIdResolver<BEANTYPE,BEANTYPE> beanIdResolver) throws UnsupportedOperationException
setBeanIdResolver
in class AbstractBeanContainer<BEANTYPE,BEANTYPE>
beanIdResolver
- to use or null to disable automatic id resolutionUnsupportedOperationException
Copyright © 2019 Vaadin Ltd. All rights reserved.