-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWatcard.java
61 lines (44 loc) · 1.45 KB
/
Watcard.java
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
package com.deange.uwaterlooapi.model.watcard;
import com.deange.uwaterlooapi.model.AbstractModel;
import com.google.auto.value.AutoValue;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
@AutoValue
public abstract class Watcard
extends AbstractModel {
public abstract List<Row> accounts();
public abstract BigDecimal total();
public String totalFormatted() {
return NumberFormat.getCurrencyInstance(Locale.CANADA).format(total());
}
public static Builder builder() {
return new AutoValue_Watcard.Builder();
}
@AutoValue.Builder
public static abstract class Builder {
public abstract Builder setAccounts(final List<Row> accounts);
public abstract Builder setTotal(final BigDecimal total);
public abstract Watcard build();
}
@AutoValue
public static abstract class Row
extends AbstractModel {
public abstract String account();
public abstract BigDecimal limit();
public abstract BigDecimal amount();
public String limitFormatted() {
return NumberFormat.getCurrencyInstance(Locale.CANADA).format(limit());
}
public String amountFormatted() {
return NumberFormat.getCurrencyInstance(Locale.CANADA).format(amount());
}
public static Row create(
final String account,
final BigDecimal limit,
final BigDecimal amount) {
return new AutoValue_Watcard_Row(account, limit, amount);
}
}
}