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.item;
19 import java.text.MessageFormat;
20 import java.util.Objects;
21 import org.mxchange.jcoreee.BaseEeSystem;
22 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
23 import org.mxchange.jshopcore.model.product.Product;
26 * An item (addedable to a basket) could respresent a product or a discount
27 * coupon. This depends on the type of the item.
29 * @author Roland Haeder
31 public abstract class BaseItem extends BaseEeSystem implements AddableBasketItem, Comparable<AddableBasketItem> {
35 private static final long serialVersionUID = 24_348_671_457_829_156L;
38 * Entry id (from database backend)
55 private String itemType;
60 private Product product;
63 public int compareTo (final AddableBasketItem item) {
65 this.getLogger().logTrace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
67 // item should not be null
69 throw new NullPointerException("item is null"); //NOI18N
73 this.getLogger().logDebug(MessageFormat.format("this.itemId={0},item.itemId={1}", this.getItemId(), item.getItemId())); //NOI18N
75 // Is the id the same?
76 if (Objects.equals(this.getItemId(), item.getItemId())) {
77 // Same id, means same item
79 } else if (this.getItemId() > item.getItemId()) {
80 // This id is larger than compared to
84 // The other id is larger
89 public Long getAmount () {
94 public void setAmount (final Long amount) {
99 public Long getId () {
104 public void setId (final Long id) {
109 public Long getItemId () {
114 public void setItemId( final Long itemId) {
115 this.itemId = itemId;
119 public String getItemType () {
120 return this.itemType;
124 public void setItemType (final String itemType) {
125 this.itemType = itemType;
129 public Product getProduct () {
134 public void setProduct (final Product product) {
135 this.product = product;