|
17 | 17 | public class TrendsTemplateData { |
18 | 18 | @Getter |
19 | 19 | private final String account; |
20 | | - private final String trendType; |
| 20 | + private final String trendPeriod; |
21 | 21 | private final List<Movement> movements; |
22 | 22 |
|
23 | 23 | private LocalDate startDate() { |
24 | | - return switch (trendType) { |
| 24 | + return switch (trendPeriod) { |
25 | 25 | case "30d" -> LocalDate.now().minusDays(30); |
26 | 26 | case "6m" -> LocalDate.now().minusMonths(5); |
27 | 27 | case "1y" -> LocalDate.now().minusMonths(11); |
28 | 28 | case "2y" -> LocalDate.now().minusYears(1).minusMonths(11); |
29 | 29 | case "5y" -> LocalDate.now().minusYears(4).minusMonths(11); |
30 | 30 | case "10y" -> LocalDate.now().minusYears(9).minusMonths(11); |
31 | | - default -> throw new IllegalStateException("Unexpected value: " + trendType); |
| 31 | + default -> throw new IllegalStateException("Unexpected value: " + trendPeriod); |
32 | 32 | }; |
33 | 33 | } |
34 | 34 |
|
35 | 35 | private String groupBy(LocalDate date) { |
36 | | - return switch (trendType) { |
| 36 | + return switch (trendPeriod) { |
37 | 37 | case "30d" -> date.format(DateTimeFormatter.ISO_LOCAL_DATE); |
38 | 38 | case "6m", "1y", "2y" -> date.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
39 | 39 | case "5y", "10y" -> date.format(DateTimeFormatter.ofPattern("yyyy")); |
40 | | - default -> throw new IllegalStateException("Unexpected value: " + trendType); |
| 40 | + default -> throw new IllegalStateException("Unexpected value: " + trendPeriod); |
41 | 41 | }; |
42 | 42 | } |
43 | 43 |
|
44 | 44 | private String toDisplayName(String groupedName) { |
45 | | - LocalDate date = switch (trendType) { |
| 45 | + LocalDate date = switch (trendPeriod) { |
46 | 46 | case "30d" -> LocalDate.parse(groupedName, DateTimeFormatter.ISO_LOCAL_DATE); |
47 | 47 | case "6m", "1y", "2y" -> LocalDate.parse(groupedName + "-01", DateTimeFormatter.ISO_LOCAL_DATE); |
48 | 48 | case "5y", "10y" -> LocalDate.parse(groupedName + "-01-01", DateTimeFormatter.ISO_LOCAL_DATE); |
49 | | - default -> throw new IllegalStateException("Unexpected value: " + trendType); |
| 49 | + default -> throw new IllegalStateException("Unexpected value: " + trendPeriod); |
50 | 50 | }; |
51 | 51 |
|
52 | | - return switch (trendType) { |
| 52 | + return switch (trendPeriod) { |
53 | 53 | case "30d" -> date.format(DateTimeFormatter.ISO_LOCAL_DATE); |
54 | 54 | case "6m", "1y" -> date.format(DateTimeFormatter.ofPattern("MMM")); |
55 | 55 | case "2y" -> date.format(DateTimeFormatter.ofPattern("MMM-yy")); |
56 | 56 | case "5y", "10y" -> date.format(DateTimeFormatter.ofPattern("yyyy")); |
57 | | - default -> throw new IllegalStateException("Unexpected value: " + trendType); |
| 57 | + default -> throw new IllegalStateException("Unexpected value: " + trendPeriod); |
58 | 58 | }; |
59 | 59 | } |
60 | 60 |
|
|
0 commit comments