1 package com.github.mygreen.cellformatter.lang;
2
3 import java.util.Collections;
4 import java.util.Date;
5 import java.util.List;
6
7
8
9
10
11
12
13
14
15
16 public class Era {
17
18
19
20
21
22 public static final Eraatter/lang/Era.html#Era">Era UNKNOWN_ERA = new Era(Collections.<EraPeriod>emptyList()) {
23
24 @Override
25 public boolean isUnkndown() {
26 return true;
27 }
28
29 };
30
31 private final List<EraPeriod> periods;
32
33
34
35
36
37
38 public Era(final List<EraPeriod> periods) {
39 ArgUtils.notNull(periods, "periods");
40
41 this.periods = Collections.unmodifiableList(periods);
42 }
43
44
45
46
47
48
49
50 public boolean contains(final Date date) {
51 ArgUtils.notNull(date, "date");
52
53 for(EraPeriod period : periods) {
54 if(period.contains(date)) {
55 return true;
56 }
57 }
58
59 return false;
60 }
61
62
63
64
65
66
67
68 public EraPeriod getTargetPeriod(final Date date) {
69 ArgUtils.notNull(date, "date");
70
71 for(EraPeriod period : periods) {
72 if(period.contains(date)) {
73 return period;
74 }
75 }
76
77 return EraPeriod.UNKNOWN_PERIOD;
78 }
79
80
81
82
83
84 public boolean isUnkndown() {
85 return false;
86 }
87
88 }