forked from AuthorizeNet/sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
163 lines (136 loc) · 3.69 KB
/
Order.java
File metadata and controls
163 lines (136 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package net.authorize.data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@XmlRootElement
/**
* General order related information.
*
*/
public class Order implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static Log logger = LogFactory.getLog(Order.class);
public static final int MAX_INVOICE_NUMBER_LENGTH = 20;
public static final int MAX_DESCRIPTION_LENGTH = 255;
public static final int MAX_ORDER_ITEM_SIZE = 30;
protected String invoiceNumber;
protected String purchaseOrderNumber;
protected String description;
protected BigDecimal totalAmount = new BigDecimal(0.00);
protected ShippingCharges shippingCharges;
protected List<OrderItem> orderItems = new ArrayList<OrderItem>();
protected Order() { }
public static Order createOrder() {
return new Order();
}
/**
* @return the invoiceNumber
*/
public String getInvoiceNumber() {
return invoiceNumber;
}
/**
* @param invoiceNumber the invoiceNumber to set
*/
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Return the total amount of the order.
*
* @return the totalAmount
*/
public BigDecimal getTotalAmount() {
return totalAmount;
}
/**
* Set the total amount of the order.
*
* @param totalAmount the totalAmount to set
*/
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
/**
* @return the orderItems
*/
public List<OrderItem> getOrderItems() {
return orderItems;
}
/**
* Sets the list of OrderItems to the list being passed in. The list will
* be truncated to 30 items, which is the max number of OrderItems allowed.
*
* @param orderItems the orderItems to set
*/
public void setOrderItems(List<OrderItem> orderItems) {
synchronized(this) {
int itemListMax = orderItems.size()>MAX_ORDER_ITEM_SIZE?MAX_ORDER_ITEM_SIZE:orderItems.size();
try {
this.orderItems = new ArrayList<OrderItem>(orderItems.subList(0, itemListMax));
} catch (Exception e) {
logger.warn("Failed setting orderItems.", e);
}
}
}
/**
* Adds an OrderItem to the list of OrderItems - provided the list of items
* isn't already at the max of 30.
*
* @param orderItem
*/
public void addOrderItem(OrderItem orderItem) {
synchronized(this) {
if(this.orderItems.size() < MAX_ORDER_ITEM_SIZE) {
this.orderItems.add(orderItem);
}
}
}
/**
* Get the shipping charges associated with this order.
*
* @return the shippingCharges
*/
public ShippingCharges getShippingCharges() {
return shippingCharges;
}
/**
* Set the shipping charges assocaited with this order.
*
* @param shippingCharges the shippingCharges to set
*/
public void setShippingCharges(ShippingCharges shippingCharges) {
this.shippingCharges = shippingCharges;
}
/**
* @return the purchaseOrderNumber
*/
public String getPurchaseOrderNumber() {
return purchaseOrderNumber;
}
/**
* @param purchaseOrderNumber the purchaseOrderNumber to set
*/
public void setPurchaseOrderNumber(String purchaseOrderNumber) {
this.purchaseOrderNumber = purchaseOrderNumber;
}
}