Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
37330 amit 1
package com.smartdukaan.cron.offercircular;
2
 
3
import java.util.Collections;
4
import java.util.List;
5
 
6
/**
7
 * One row of the Pine Labs affordability circular, exactly as printed.
8
 *
9
 * The nine columns are kept verbatim - no interpretation happens here. Everything
10
 * downstream (benefit amounts, tenures, banks, products) is derived from these
11
 * strings, and they are also what the review screen displays, so a row that cannot
12
 * be parsed is still recorded rather than dropped.
13
 */
14
public class CircularRow {
15
 
16
    private final int pageNo;
17
    private final int rowNo;
18
    private final String oemLabel;
19
    private final String additionalCashback;
20
    private final String description;
21
    private final String emiTenure;
22
    private final String debitCards;
23
    private final String creditCards;
24
    private final String eligibleProducts;
25
    private final String startDateRaw;
26
    private final String endDateRaw;
27
 
28
    /** @param middle the six cells between the OEM label and the two dates */
29
    public CircularRow(int pageNo, int rowNo, String oemLabel, List<String> middle,
30
                       String startDateRaw, String endDateRaw) {
31
        if (middle == null || middle.size() != MIDDLE_CELL_COUNT) {
32
            throw new IllegalArgumentException(
33
                    "expected " + MIDDLE_CELL_COUNT + " middle cells, got "
34
                            + (middle == null ? "null" : middle.size()));
35
        }
36
        this.pageNo = pageNo;
37
        this.rowNo = rowNo;
38
        this.oemLabel = oemLabel;
39
        this.additionalCashback = middle.get(0);
40
        this.description = middle.get(1);
41
        this.emiTenure = middle.get(2);
42
        this.debitCards = middle.get(3);
43
        this.creditCards = middle.get(4);
44
        this.eligibleProducts = middle.get(5);
45
        this.startDateRaw = startDateRaw;
46
        this.endDateRaw = endDateRaw;
47
    }
48
 
49
    public static final int MIDDLE_CELL_COUNT = 6;
50
 
51
    public int getPageNo() { return pageNo; }
52
    public int getRowNo() { return rowNo; }
53
    public String getOemLabel() { return oemLabel; }
54
    public String getAdditionalCashback() { return additionalCashback; }
55
    public String getDescription() { return description; }
56
    public String getEmiTenure() { return emiTenure; }
57
    public String getDebitCards() { return debitCards; }
58
    public String getCreditCards() { return creditCards; }
59
    public String getEligibleProducts() { return eligibleProducts; }
60
    public String getStartDateRaw() { return startDateRaw; }
61
    public String getEndDateRaw() { return endDateRaw; }
62
 
63
    public List<String> getMiddleCells() {
64
        return Collections.unmodifiableList(java.util.Arrays.asList(
65
                additionalCashback, description, emiTenure,
66
                debitCards, creditCards, eligibleProducts));
67
    }
68
 
69
    @Override
70
    public String toString() {
71
        return "p" + pageNo + "r" + rowNo + " [" + oemLabel + "] " + description
72
                + " | " + startDateRaw + " -> " + endDateRaw;
73
    }
74
}