2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jshopcore.model.basket;
22 * A general basket class
24 * @author Roland Haeder
25 * @param <T> Any instance that implements AddableBasketItem
27 public abstract class BaseBasket<T extends AddableBasketItem> implements Basket<T> {
31 private static final long serialVersionUID = 782_396_762_230_845_717L;
34 * Protected constructor with session instance
36 protected BaseBasket () {
44 public void addItem (final T item) {
45 // item must not be null
48 throw new NullPointerException("item is null"); //NOI18N
49 } else if (this.isAdded(item)) {
51 throw new IllegalArgumentException("item has already been added. Did you miss to call isAdded()?"); //NOI18N
54 // Add item to database
55 // TODO: ((BasketFrontend) this.getFrontend()).addItem(item, this.getSessionId());
59 public boolean isEmpty () {
60 // Deligate call to frontend
61 // TODO: return ((BasketFrontend) this.getFrontend()).isEmpty();
62 throw new UnsupportedOperationException("Not yet implmeneted.");
66 public Map<Long, T> getAll () {
68 // TODO: Map<Long, T> map = ((BasketFrontend) this.getFrontend()).getAll();
69 Map<Long, T> map = null;
77 // Deligate to frontend
78 // TODO: return ((BasketFrontend) this.getFrontend()).getLast();
79 throw new UnsupportedOperationException("Not yet implmeneted.");
83 public int getLastNumRows () {
84 // Deligate to frontend
85 // TODO: return this.getFrontend().getLastNumRows();
86 throw new UnsupportedOperationException("Not yet implmeneted.");
90 public boolean isAdded (final T item) {
91 // item must not be null
94 throw new NullPointerException("item is null"); //NOI18N
98 // TODO: boolean isAdded = ((BasketFrontend) this.getFrontend()).isAdded(item, this.getSessionId());
99 boolean isAdded = true;