|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.hivemind; |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| public abstract class Occurances |
|
23 |
| { |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| public static final Occurances UNBOUNDED = new Occurances("UNBOUNDED") |
|
28 |
| { |
|
29 |
1030
| public boolean inRange(int count)
|
|
30 |
| { |
|
31 |
1030
| return true;
|
|
32 |
| } |
|
33 |
| }; |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| public static final Occurances OPTIONAL = new Occurances("OPTIONAL") |
|
40 |
| { |
|
41 |
4
| public boolean inRange(int count)
|
|
42 |
| { |
|
43 |
4
| return count < 2;
|
|
44 |
| } |
|
45 |
| }; |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| public static final Occurances REQUIRED = new Occurances("REQUIRED") |
|
52 |
| { |
|
53 |
486
| public boolean inRange(int count)
|
|
54 |
| { |
|
55 |
486
| return count == 1;
|
|
56 |
| } |
|
57 |
| }; |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| public static final Occurances ONE_PLUS = new Occurances("ONE_PLUS") |
|
64 |
| { |
|
65 |
13
| public boolean inRange(int count)
|
|
66 |
| { |
|
67 |
13
| return count > 0;
|
|
68 |
| } |
|
69 |
| }; |
|
70 |
| |
|
71 |
| public static final Occurances NONE = new Occurances("NONE") |
|
72 |
| { |
|
73 |
8
| public boolean inRange(int count)
|
|
74 |
| { |
|
75 |
8
| return count == 0;
|
|
76 |
| } |
|
77 |
| }; |
|
78 |
| |
|
79 |
| private String _name; |
|
80 |
| |
|
81 |
5
| private Occurances(String name)
|
|
82 |
| { |
|
83 |
5
| _name = name;
|
|
84 |
| } |
|
85 |
| |
|
86 |
4
| public String getName()
|
|
87 |
| { |
|
88 |
4
| return _name;
|
|
89 |
| } |
|
90 |
| |
|
91 |
2
| public String toString()
|
|
92 |
| { |
|
93 |
2
| return "Occurances[" + _name + "]";
|
|
94 |
| } |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| public abstract boolean inRange(int count); |
|
104 |
| |
|
105 |
| } |