diff options
author | Henri Sara <henri.sara@itmill.com> | 2010-11-29 14:34:38 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2010-11-29 14:34:38 +0000 |
commit | f6e41dc7c8666146595bc6aa66102f7cfc9c37cb (patch) | |
tree | 1b08e1a6078c7ffe1ed84541b536ec0e72a16d88 /src/com/vaadin/data/util/BeanContainer.java | |
parent | 793db04ae4e654650e18e5a39f247daaf128f3a6 (diff) | |
download | vaadin-framework-f6e41dc7c8666146595bc6aa66102f7cfc9c37cb.tar.gz vaadin-framework-f6e41dc7c8666146595bc6aa66102f7cfc9c37cb.zip |
#5713 BeanContainer that does not require item id to be the bean
svn changeset:16216/svn branch:6.5
Diffstat (limited to 'src/com/vaadin/data/util/BeanContainer.java')
-rw-r--r-- | src/com/vaadin/data/util/BeanContainer.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/com/vaadin/data/util/BeanContainer.java b/src/com/vaadin/data/util/BeanContainer.java new file mode 100644 index 0000000000..9c264b9dce --- /dev/null +++ b/src/com/vaadin/data/util/BeanContainer.java @@ -0,0 +1,95 @@ +package com.vaadin.data.util; + +import com.vaadin.data.Item; + +/** + * An in-memory container for JavaBeans. + * + * <p> + * 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. + * </p> + * + * <p> + * In BeanContainer (unlike {@link BeanItemContainer}), the item IDs do not have + * to be the beans themselves. + * </p> + * + * <p> + * It is not possible to add additional properties to the container and nested + * bean properties are not supported. + * </p> + * + * @param <IDTYPE> + * The type of the item identifier + * @param <BT> + * The type of the Bean + * + * @see AbstractBeanContainer + * @see BeanItemContainer + * + * @since 6.5 + */ +public class BeanContainer<IDTYPE, BT> extends + AbstractBeanContainer<IDTYPE, BT> { + + public BeanContainer(Class<? extends BT> type) { + super(type); + } + + public Item addItemAt(int index, Object newItemId) + throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + + public Item addItemAfter(Object previousItemId, Object newItemId) + throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + + public Item addItem(Object itemId) throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + + /** + * Adds the bean to the Container. + * + * @see com.vaadin.data.Container#addItem(Object) + */ + @Override + public BeanItem<BT> addItem(IDTYPE itemId, BT bean) { + return super.addItem(itemId, bean); + } + + /** + * Adds the bean after the given bean. + * + * @see com.vaadin.data.Container.Ordered#addItemAfter(Object, Object) + */ + @Override + public BeanItem<BT> addItemAfter(IDTYPE previousItemId, IDTYPE newItemId, + BT bean) { + return super.addItemAfter(previousItemId, newItemId, bean); + } + + /** + * Adds a new bean at the given index. + * + * The bean is used both as the item contents and as the item identifier. + * + * @param index + * Index at which the bean should be added. + * @param newItemId + * The item id for the bean to add to the container. + * @param bean + * The bean to add to the container. + * + * @return Returns the new BeanItem or null if the operation fails. + */ + @Override + public BeanItem<BT> addItemAt(int index, IDTYPE newItemId, BT bean) { + return super.addItemAt(index, newItemId, bean); + } + +} |