KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > domain > OrderItem


1 /*
2  * Created on Feb 22, 2003
3  */

4 package xpetstore.domain;
5
6 import java.io.Serializable JavaDoc;
7
8
9 /**
10  * @author <a HREF="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
11  *
12  * @hibernate.class
13  * table="T_ORDER_ITEM"
14  */

15 public class OrderItem
16     implements Serializable JavaDoc
17 {
18     //~ Instance fields --------------------------------------------------------
19

20     private Item _item;
21     private long _orderItemId;
22     private int _quantity;
23     private double _unitPrice;
24
25     //~ Constructors -----------------------------------------------------------
26

27     public OrderItem( ) {}
28
29     public OrderItem( Item item,
30                       int quantity )
31     {
32         _item = item;
33         _quantity = quantity;
34         _unitPrice = item.getListPrice( );
35     }
36
37     //~ Methods ----------------------------------------------------------------
38

39     /**
40      * @return Item
41      *
42      * @hibernate.many-to-one
43      * column="item_fk"
44      * cascade="none"
45      */

46     public Item getItem( )
47     {
48         return _item;
49     }
50
51     /**
52      * @return long
53      *
54      * @hibernate.id
55      * generator-class="vm.long"
56      */

57     public long getOrderItemId( )
58     {
59         return _orderItemId;
60     }
61
62     /**
63      * @return int
64      *
65      * @hibernate.property
66      */

67     public int getQuantity( )
68     {
69         return _quantity;
70     }
71
72     public double getSubTotal( )
73     {
74         return _quantity * _unitPrice;
75     }
76
77     /**
78      * @return double
79      *
80      * @hibernate.property
81      */

82     public double getUnitPrice( )
83     {
84         return _unitPrice;
85     }
86
87     /**
88      * Sets the item.
89      * @param item The item to set
90      */

91     public void setItem( Item item )
92     {
93         _item = item;
94     }
95
96     /**
97      * Sets the orderItemUId.
98      * @param orderItemUId The orderItemUId to set
99      */

100     public void setOrderItemId( long orderItemUId )
101     {
102         _orderItemId = orderItemUId;
103     }
104
105     /**
106      * Sets the quantity.
107      * @param quantity The quantity to set
108      */

109     public void setQuantity( int quantity )
110     {
111         this._quantity = quantity;
112     }
113
114     /**
115      * Sets the unitPrice.
116      * @param unitPrice The unitPrice to set
117      */

118     public void setUnitPrice( double unitPrice )
119     {
120         _unitPrice = unitPrice;
121     }
122 }
123
Popular Tags