]> git.mxchange.org Git - jcustomer-core.git/blob - src/org/mxchange/jshopcore/model/order/items/OrderItem.java
auto-formatted project + updated jars
[jcustomer-core.git] / src / org / mxchange / jshopcore / model / order / items / OrderItem.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jshopcore.model.order.items;
18
19 import javax.persistence.Basic;
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.GenerationType;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.OneToOne;
27 import javax.persistence.Table;
28 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
29 import org.mxchange.jshopcore.model.basket.items.BaseItem;
30 import org.mxchange.jshopcore.model.product.GenericProduct;
31 import org.mxchange.jshopcore.model.product.Product;
32
33 /**
34  * A general basket item
35  * <p>
36  * @author Roland Haeder<roland@mxchange.org>
37  */
38 @Entity (name = "ordered_item")
39 @Table (name = "ordered_items")
40 public class OrderItem extends BaseItem implements AddableBasketItem {
41
42         /**
43          * Serial number
44          */
45         private static final long serialVersionUID = 44_189_562_738_723_581L;
46
47         /**
48          * Item amount
49          */
50         @Basic (optional = false)
51         @Column (name = "amount", length = 20, nullable = false)
52         private Long amount;
53
54         /**
55          * Entry id (from database backend)
56          */
57         @Id
58         @GeneratedValue (strategy = GenerationType.IDENTITY)
59         @Column (name = "id", nullable = false, length = 20)
60         private Long id;
61
62         /**
63          * Item type
64          */
65         @Basic (optional = false)
66         @Column (name = "item_type", length = 20)
67         private String itemType;
68
69         /**
70          * Product instance
71          */
72         @JoinColumn (name = "product_id", updatable = false)
73         @OneToOne (targetEntity = GenericProduct.class)
74         private Product product;
75
76         /**
77          * Default constructor
78          */
79         public OrderItem () {
80         }
81
82         @Override
83         public Long getOrderedAmount () {
84                 return this.amount;
85         }
86
87         @Override
88         public void setOrderedAmount (final Long amount) {
89                 this.amount = amount;
90         }
91
92         @Override
93         public Long getItemId () {
94                 return this.id;
95         }
96
97         @Override
98         public void setItemId (final Long id) {
99                 this.id = id;
100         }
101
102         @Override
103         public String getItemType () {
104                 return this.itemType;
105         }
106
107         @Override
108         public void setItemType (final String itemType) {
109                 this.itemType = itemType;
110         }
111
112         @Override
113         public Product getItemProduct () {
114                 return this.product;
115         }
116
117         @Override
118         public void setItemProduct (final Product product) {
119                 this.product = product;
120         }
121 }