wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
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
/*  Copyright (C) 2023-2024 José Rebelo
 
    This file is part of Gadgetbridge.
 
    Gadgetbridge is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    Gadgetbridge is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
 
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards;
 
import androidx.annotation.Nullable;
 
import org.apache.commons.lang3.builder.CompareToBuilder;
 
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;
import java.util.Locale;
 
public class LoyaltyCard implements Serializable, Comparable<LoyaltyCard> {
 
    private final int id;
    private final String name;
    private final String note;
    private final Date expiry;
    private final BigDecimal balance;
    private final Currency balanceType;
    private final String cardId;
 
    @Nullable
    private final String barcodeId;
 
    @Nullable
    private final BarcodeFormat barcodeFormat;
 
    @Nullable
    private final Integer color;
 
    private final boolean starred;
    private final boolean archived;
    private final long lastUsed;
 
    public LoyaltyCard(final int id,
                       final String name,
                       final String note,
                       final Date expiry,
                       final BigDecimal balance,
                       final Currency balanceType,
                       final String cardId,
                       @Nullable final String barcodeId,
                       @Nullable final BarcodeFormat barcodeFormat,
                       @Nullable final Integer color,
                       final boolean starred,
                       final boolean archived,
                       final long lastUsed) {
        this.id = id;
        this.name = name;
        this.note = note;
        this.expiry = expiry;
        this.balance = balance;
        this.balanceType = balanceType;
        this.cardId = cardId;
        this.barcodeId = barcodeId;
        this.barcodeFormat = barcodeFormat;
        this.color = color;
        this.starred = starred;
        this.archived = archived;
        this.lastUsed = lastUsed;
    }
 
    public int getId() {
        return id;
    }
 
    public String getName() {
        return name;
    }
 
    public String getNote() {
        return note;
    }
 
    public Date getExpiry() {
        return expiry;
    }
 
    public BigDecimal getBalance() {
        return balance;
    }
 
    public Currency getBalanceType() {
        return balanceType;
    }
 
    public String getCardId() {
        return cardId;
    }
 
    @Nullable
    public String getBarcodeId() {
        return barcodeId;
    }
 
    @Nullable
    public BarcodeFormat getBarcodeFormat() {
        return barcodeFormat;
    }
 
    @Nullable
    public Integer getColor() {
        return color;
    }
 
    public boolean isStarred() {
        return starred;
    }
 
    public boolean isArchived() {
        return archived;
    }
 
    public long getLastUsed() {
        return lastUsed;
    }
 
    @Override
    public String toString() {
        return String.format(
                Locale.ROOT,
                "LoyaltyCard{id=%s, name=%s, cardId=%s}",
                id, name, cardId
        );
    }
 
    @Override
    public int compareTo(final LoyaltyCard o) {
        return new CompareToBuilder()
                .append(isStarred(), o.isStarred())
                .append(isArchived(), o.isArchived())
                .append(getName(), o.getName())
                .append(getCardId(), o.getCardId())
                .build();
    }
}