Subversion Repositories SmartDukaan

Rev

Rev 3546 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3546 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.utils;
5
 
4142 mandeep.dh 6
import in.shop2020.model.v1.catalog.Item;
3546 mandeep.dh 7
import in.shop2020.model.v1.order.LineItem;
8
import in.shop2020.model.v1.order.Order;
9
 
10
/**
11
 * @author mandeep
12
 *
13
 */
14
public class ModelUtils {
15
    public static String extractAddressFromOrder(Order order) {
16
        StringBuilder address = new StringBuilder();
17
        if (order.getCustomer_address1() != null) {
18
            address.append(order.getCustomer_address1() + ", ");
19
        }
20
        if (order.getCustomer_address2() != null) {
21
            address.append(order.getCustomer_address2() + ", ");
22
        }
23
        if (order.getCustomer_city() != null) {
24
            address.append(order.getCustomer_city() + ", ");
25
        }
26
        if (order.getCustomer_state() != null) {
27
            address.append(order.getCustomer_state() + "-");
28
        }
29
        if (order.getCustomer_pincode() != null) {
30
            address.append(order.getCustomer_pincode());
31
        }
32
 
33
        return address.toString();
34
    }
35
 
36
    public static String extractProductNameFromLineItem(LineItem lineItem) {
37
        StringBuilder productName = new StringBuilder();
38
 
39
        if (lineItem.getBrand() != null && !lineItem.getBrand().isEmpty()) {
40
            productName.append(lineItem.getBrand() + " ");
41
        }
42
 
43
        if (lineItem.getModel_name() != null && !lineItem.getModel_name().isEmpty()) {
44
            productName.append(lineItem.getModel_name()  + " ");
45
        }
46
 
47
        if (lineItem.getModel_number() != null && !lineItem.getModel_number().isEmpty()) {
48
            productName.append(lineItem.getModel_number()  + " ");
49
        }
50
 
51
        return productName.toString();
52
    }
4142 mandeep.dh 53
 
54
    public static String extractProductNameFromItem(Item lineItem) {
55
        StringBuilder productName = new StringBuilder();
56
 
57
        if (lineItem.getBrand() != null && !lineItem.getBrand().isEmpty()) {
58
            productName.append(lineItem.getBrand() + " ");
59
        }
60
 
61
        if (lineItem.getModelName() != null && !lineItem.getModelName().isEmpty()) {
62
            productName.append(lineItem.getModelName()  + " ");
63
        }
64
 
65
        if (lineItem.getModelNumber() != null && !lineItem.getModelNumber().isEmpty()) {
66
            productName.append(lineItem.getModelNumber()  + " ");
67
        }
68
 
69
        return productName.toString();
70
    }
71
 
3546 mandeep.dh 72
}