From 7a7cb2cdbda568d380a3cf4a8b1084e2d059c758 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 30 Nov 2010 12:59:26 +0000 Subject: [PATCH] #5713 etc.: some BeanContainer, BeanItemContainer and AbstractBeanContainer changes based on review (API, generics, suppress warnings) svn changeset:16231/svn branch:6.5 --- src/com/vaadin/data/util/AbstractBeanContainer.java | 6 +++--- src/com/vaadin/data/util/BeanContainer.java | 2 +- src/com/vaadin/data/util/BeanItemContainer.java | 13 ++++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/com/vaadin/data/util/AbstractBeanContainer.java b/src/com/vaadin/data/util/AbstractBeanContainer.java index bb49297c4f..00e96e3a68 100644 --- a/src/com/vaadin/data/util/AbstractBeanContainer.java +++ b/src/com/vaadin/data/util/AbstractBeanContainer.java @@ -92,7 +92,7 @@ public abstract class AbstractBeanContainer implements Indexed, /** * The type of the beans in the container. */ - private final Class type; + private final Class type; /** * A description of the properties found in beans of type {@link #type}. @@ -114,7 +114,7 @@ public abstract class AbstractBeanContainer implements Indexed, * @throws IllegalArgumentException * If {@code type} is null */ - public AbstractBeanContainer(Class type) { + protected AbstractBeanContainer(Class type) { if (type == null) { throw new IllegalArgumentException( "The bean type passed to AbstractBeanContainer must not be null"); @@ -161,7 +161,7 @@ public abstract class AbstractBeanContainer implements Indexed, * * @return */ - public Class getBeanType() { + public Class getBeanType() { return type; } diff --git a/src/com/vaadin/data/util/BeanContainer.java b/src/com/vaadin/data/util/BeanContainer.java index 9c264b9dce..81d89cdddb 100644 --- a/src/com/vaadin/data/util/BeanContainer.java +++ b/src/com/vaadin/data/util/BeanContainer.java @@ -34,7 +34,7 @@ import com.vaadin.data.Item; public class BeanContainer extends AbstractBeanContainer { - public BeanContainer(Class type) { + public BeanContainer(Class type) { super(type); } diff --git a/src/com/vaadin/data/util/BeanItemContainer.java b/src/com/vaadin/data/util/BeanItemContainer.java index aaa9a66675..78a2356a97 100644 --- a/src/com/vaadin/data/util/BeanItemContainer.java +++ b/src/com/vaadin/data/util/BeanItemContainer.java @@ -44,7 +44,7 @@ public class BeanItemContainer extends AbstractBeanContainer { * @throws IllegalArgumentException * If {@code type} is null */ - public BeanItemContainer(Class type) + public BeanItemContainer(Class type) throws IllegalArgumentException { super(type); } @@ -69,10 +69,13 @@ public class BeanItemContainer extends AbstractBeanContainer { * * @deprecated use {@link #BeanItemContainer(Class, Collection)} instead */ + @SuppressWarnings("unchecked") @Deprecated public BeanItemContainer(Collection collection) throws IllegalArgumentException { - super(getBeanClassForCollection(collection)); + // must assume the class is BT + // the class information is erased by the compiler + super((Class) getBeanClassForCollection(collection)); addAll(collection); } @@ -86,6 +89,7 @@ public class BeanItemContainer extends AbstractBeanContainer { * @return * @throws IllegalArgumentException */ + @SuppressWarnings("unchecked") @Deprecated private static Class getBeanClassForCollection( Collection collection) @@ -107,7 +111,7 @@ public class BeanItemContainer extends AbstractBeanContainer { * @throws IllegalArgumentException * If {@code type} is null */ - public BeanItemContainer(Class type, + public BeanItemContainer(Class type, Collection collection) throws IllegalArgumentException { super(type); @@ -167,6 +171,7 @@ public class BeanItemContainer extends AbstractBeanContainer { * * @see com.vaadin.data.Container.Ordered#addItemAfter(Object, Object) */ + @SuppressWarnings("unchecked") public BeanItem addItemAfter(Object previousItemId, Object newItemId) { return super.addItemAfter((BT) previousItemId, (BT) newItemId, (BT) newItemId); @@ -183,6 +188,7 @@ public class BeanItemContainer extends AbstractBeanContainer { * The bean to add to the container. * @return Returns the new BeanItem or null if the operation fails. */ + @SuppressWarnings("unchecked") public BeanItem addItemAt(int index, Object newItemId) { return super.addItemAt(index, (BT) newItemId, (BT) newItemId); } @@ -194,6 +200,7 @@ public class BeanItemContainer extends AbstractBeanContainer { * * @see com.vaadin.data.Container#addItem(Object) */ + @SuppressWarnings("unchecked") public BeanItem addItem(Object itemId) { BeanItem beanItem = addItem((BT) itemId, (BT) itemId); -- 2.39.5