-
Notifications
You must be signed in to change notification settings - Fork 383
/
PrimitiveTypes.java
203 lines (185 loc) · 5.23 KB
/
PrimitiveTypes.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* Copyright 2017-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.atomix;
import io.atomix.counter.AtomicCounterType;
import io.atomix.election.LeaderElectionType;
import io.atomix.election.LeaderElectorType;
import io.atomix.generator.AtomicIdGeneratorType;
import io.atomix.lock.DistributedLockType;
import io.atomix.map.AtomicCounterMapType;
import io.atomix.map.ConsistentMapType;
import io.atomix.map.ConsistentTreeMapType;
import io.atomix.multimap.ConsistentMultimapType;
import io.atomix.primitive.Ordering;
import io.atomix.primitive.PrimitiveTypeRegistry;
import io.atomix.queue.WorkQueueType;
import io.atomix.set.DistributedSetType;
import io.atomix.tree.DocumentTreeType;
import io.atomix.value.AtomicValueType;
/**
* Primitive types.
*/
public final class PrimitiveTypes {
/**
* Returns a new atomic counter type.
*
* @return a new atomic counter type
*/
public static AtomicCounterType counter() {
return AtomicCounterType.instance();
}
/**
* Returns a new atomic ID generator type.
*
* @return a new atomic ID generator type
*/
public static AtomicIdGeneratorType idGenerator() {
return AtomicIdGeneratorType.instance();
}
/**
* Returns a new leader election type.
*
* @param <T> the election candidate type
* @return a new leader election type
*/
public static <T> LeaderElectionType<T> leaderElection() {
return LeaderElectionType.instance();
}
/**
* Returns a new leader elector type.
*
* @param <T> the election candidate type
* @return a new leader elector type
*/
public static <T> LeaderElectorType<T> leaderElector() {
return LeaderElectorType.instance();
}
/**
* Returns a new distributed lock type.
*
* @return a new distributed lock type
*/
public static DistributedLockType lock() {
return DistributedLockType.instance();
}
/**
* Returns a new atomic counter map type.
*
* @param <K> the key type
* @return a new atomic counter map type
*/
public static <K> AtomicCounterMapType<K> counterMap() {
return AtomicCounterMapType.instance();
}
/**
* Returns a new consistent map type.
*
* @param <K> the key type
* @param <V> the value type
* @return a new consistent map type
*/
public static <K, V> ConsistentMapType<K, V> map() {
return ConsistentMapType.instance();
}
/**
* Returns a new consistent tree map type.
*
* @param <V> the value type
* @return a new consistent tree map type
*/
public static <V> ConsistentTreeMapType<V> treeMap() {
return ConsistentTreeMapType.instance();
}
/**
* Returns a new consistent multimap type.
*
* @param <K> the key type
* @param <V> the value type
* @return a new consistent multimap type
*/
public static <K, V> ConsistentMultimapType<K, V> multimap() {
return ConsistentMultimapType.instance();
}
/**
* Returns a new distributed set type.
*
* @param <E> the set element type
* @return a new distributed set type
*/
public static <E> DistributedSetType<E> set() {
return DistributedSetType.instance();
}
/**
* Returns a new document tree type.
*
* @param <V> the tree value type
* @return a new document tree type
*/
public static <V> DocumentTreeType<V> tree() {
return DocumentTreeType.instance();
}
/**
* Returns a new document tree type.
*
* @param <V> the tree value type
* @return a new document tree type
*/
public static <V> DocumentTreeType<V> tree(Ordering ordering) {
return DocumentTreeType.ordered(ordering);
}
/**
* Returns a new value type.
*
* @param <V> the value value type
* @return the value type
*/
public static <V> AtomicValueType<V> value() {
return AtomicValueType.instance();
}
/**
* Returns a new work queue type instance.
*
* @param <E> the element type
* @return a new work queue type
*/
public static <E> WorkQueueType<E> workQueue() {
return WorkQueueType.instance();
}
/**
* Registers primitive types on the given registry.
*
* @param registry the primitive type registry
*/
static void register(PrimitiveTypeRegistry registry) {
registry.register(counter());
registry.register(idGenerator());
registry.register(leaderElection());
registry.register(leaderElector());
registry.register(lock());
registry.register(counterMap());
registry.register(map());
registry.register(treeMap());
registry.register(multimap());
registry.register(set());
registry.register(tree());
registry.register(tree(Ordering.NATURAL));
registry.register(tree(Ordering.INSERTION));
registry.register(value());
registry.register(workQueue());
}
private PrimitiveTypes() {
}
}