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. This class does not store any properties, it only
23 * contains logic for handling the items (T).
25 * @author Roland Haeder
26 * @param <T> Any instance that implements AddableBasketItem
28 public abstract class BaseBasket<T extends AddableBasketItem> implements Basket<T> {
32 private static final long serialVersionUID = 782_396_762_230_845_717L;
35 * Protected constructor with session instance
37 protected BaseBasket () {
45 public void addItem (final T item) {
46 // item must not be null
49 throw new NullPointerException("item is null"); //NOI18N
50 } else if (this.isAdded(item)) {
52 throw new IllegalArgumentException("item has already been added. Did you miss to call isAdded()?"); //NOI18N
55 // Add item to database
56 // TODO: ((BasketFrontend) this.getFrontend()).addItem(item, this.getSessionId());
60 public boolean isEmpty () {
61 // Deligate call to frontend
62 // TODO: return ((BasketFrontend) this.getFrontend()).isEmpty();
63 throw new UnsupportedOperationException("Not yet implmeneted.");
67 public Map<Long, T> getAll () {
69 // TODO: Map<Long, T> map = ((BasketFrontend) this.getFrontend()).getAll();
70 Map<Long, T> map = null;
78 // Deligate to frontend
79 // TODO: return ((BasketFrontend) this.getFrontend()).getLast();
80 throw new UnsupportedOperationException("Not yet implmeneted.");
84 public int getLastNumRows () {
85 // Deligate to frontend
86 // TODO: return this.getFrontend().getLastNumRows();
87 throw new UnsupportedOperationException("Not yet implmeneted.");
91 public boolean isAdded (final T item) {
92 // item must not be null
95 throw new NullPointerException("item is null"); //NOI18N
99 // TODO: boolean isAdded = ((BasketFrontend) this.getFrontend()).isAdded(item, this.getSessionId());
100 boolean isAdded = true;