| 3546 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.utils;
|
|
|
5 |
|
|
|
6 |
import in.shop2020.model.v1.order.LineItem;
|
|
|
7 |
import in.shop2020.model.v1.order.Order;
|
|
|
8 |
|
|
|
9 |
/**
|
|
|
10 |
* @author mandeep
|
|
|
11 |
*
|
|
|
12 |
*/
|
|
|
13 |
public class ModelUtils {
|
|
|
14 |
public static String extractAddressFromOrder(Order order) {
|
|
|
15 |
StringBuilder address = new StringBuilder();
|
|
|
16 |
if (order.getCustomer_address1() != null) {
|
|
|
17 |
address.append(order.getCustomer_address1() + ", ");
|
|
|
18 |
}
|
|
|
19 |
if (order.getCustomer_address2() != null) {
|
|
|
20 |
address.append(order.getCustomer_address2() + ", ");
|
|
|
21 |
}
|
|
|
22 |
if (order.getCustomer_city() != null) {
|
|
|
23 |
address.append(order.getCustomer_city() + ", ");
|
|
|
24 |
}
|
|
|
25 |
if (order.getCustomer_state() != null) {
|
|
|
26 |
address.append(order.getCustomer_state() + "-");
|
|
|
27 |
}
|
|
|
28 |
if (order.getCustomer_pincode() != null) {
|
|
|
29 |
address.append(order.getCustomer_pincode());
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
return address.toString();
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public static String extractProductNameFromLineItem(LineItem lineItem) {
|
|
|
36 |
StringBuilder productName = new StringBuilder();
|
|
|
37 |
|
|
|
38 |
if (lineItem.getBrand() != null && !lineItem.getBrand().isEmpty()) {
|
|
|
39 |
productName.append(lineItem.getBrand() + " ");
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
if (lineItem.getModel_name() != null && !lineItem.getModel_name().isEmpty()) {
|
|
|
43 |
productName.append(lineItem.getModel_name() + " ");
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
if (lineItem.getModel_number() != null && !lineItem.getModel_number().isEmpty()) {
|
|
|
47 |
productName.append(lineItem.getModel_number() + " ");
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
return productName.toString();
|
|
|
51 |
}
|
|
|
52 |
}
|