* A general basket class
*
* @author Roland Haeder
+ * @param <T> Any instance that implements AddableBasketItem
*/
-public class BaseBasket extends BaseFrameworkSystem implements Basket<AddableBasketItem>, Serializable {
+public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem implements Basket<T>, Serializable {
/**
* Serial number
*/
/**
* Item map
*/
- private final Map<Long, AddableBasketItem> items;
+ private final Map<Long, T> items;
/**
* Protected constructor with session instance
}
@Override
- public void addItem (final AddableBasketItem item) {
+ public void addItem (final T item) {
// Trace call
this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
}
@Override
- public AddableBasketItem getItem (final Product product) {
+ public T getItem (final Product product) {
// Trace message
this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
this.getLogger().debug("Product " + product.getTitle() + " has id " + product.getId()); //NOI18N
// Get item instance from map by product's id number (both are the same)
- AddableBasketItem item = this.items.get(product.getId());
+ T item = this.items.get(product.getId());
// Is it null?
if (item == null) {
}
@Override
- public boolean isItemAdded (final AddableBasketItem item) {
+ public boolean isItemAdded (final T item) {
// Trace call
this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
* A basket for orderable items
*
* @author Roland Haeder
+ * @param <T> Any instance that implements AddableBasketItem
*/
-public class ItemBasket extends BaseBasket implements Basket<AddableBasketItem> {
+public class ItemBasket<T extends AddableBasketItem> extends BaseBasket<T> implements Basket<T> {
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 4384123923163957L;
/**
* Creates a singleton instance from given session's id