RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
PrefixMap.java
1
/*
2
* Copyright (C) 2018-2021 Niels Basjes
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* https://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
package
org.wpilib.util.collections;
18
19
import
java.util.Collection;
20
import
java.util.Iterator;
21
import
java.util.Map;
22
import
java.util.PrimitiveIterator;
23
import
java.util.Set;
24
import
java.util.stream.IntStream;
25
43
public
interface
PrefixMap
<V>
extends
Map<String, V> {
49
@Override
50
int
size
();
51
57
@Override
58
default
boolean
isEmpty
() {
59
return
size
() == 0;
60
}
61
69
@Override
70
default
void
putAll
(Map<? extends String, ? extends V> prefixesAndValues) {
71
prefixesAndValues.forEach(this::put);
72
}
73
87
@Override
88
V
put
(String prefix, V value);
89
97
default
V
remove
(String prefix) {
98
throw
new
UnsupportedOperationException(
99
"The 'remove(String prefix)' method has not been implemented in "
100
+ this.getClass().getCanonicalName());
101
}
102
103
@Override
104
default
V
remove
(Object o) {
105
if
(o instanceof String) {
106
return
remove
((String) o);
107
}
108
return
null
;
109
}
110
111
@Override
112
default
boolean
containsKey(Object o) {
113
throw
new
UnsupportedOperationException(
114
"The 'containsKey(Object o)' method has not been implemented in "
115
+ this.getClass().getCanonicalName());
116
}
117
118
@Override
119
default
boolean
containsValue(Object o) {
120
throw
new
UnsupportedOperationException(
121
"The 'containsValue(Object o)' method has not been implemented in "
122
+ this.getClass().getCanonicalName());
123
}
124
134
V
get
(String prefix);
135
145
@Override
146
default
V
get
(Object prefix) {
147
if
(prefix instanceof String) {
148
return
get
((String) prefix);
149
}
150
return
null
;
151
}
152
153
@Override
154
default
Set<String> keySet() {
155
throw
new
UnsupportedOperationException(
156
"The 'keySet()' method has not been implemented in "
+ this.getClass().getCanonicalName());
157
}
158
159
@Override
160
default
Collection<V> values() {
161
throw
new
UnsupportedOperationException(
162
"The 'values()' method has not been implemented in "
+ this.getClass().getCanonicalName());
163
}
164
171
@Override
172
default
void
clear
() {
173
throw
new
UnsupportedOperationException(
174
"The 'clear()' method has not been implemented in "
+ this.getClass().getCanonicalName());
175
}
176
183
default
boolean
containsPrefix
(String prefix) {
184
return
containsPrefix
(prefix.codePoints().iterator());
185
}
186
193
default
boolean
containsPrefix
(
int
[] prefix) {
194
return
containsPrefix
(IntStream.of(prefix).iterator());
195
}
196
203
boolean
containsPrefix
(PrimitiveIterator.OfInt prefix);
204
214
default
V
getShortestMatch
(String input) {
215
return
getShortestMatch
(input.codePoints().iterator());
216
}
217
228
default
V
getShortestMatch
(
int
[] input) {
229
return
getShortestMatch
(IntStream.of(input).iterator());
230
}
231
242
V
getShortestMatch
(PrimitiveIterator.OfInt input);
243
253
default
V
getLongestMatch
(String input) {
254
return
getLongestMatch
(input.codePoints().iterator());
255
}
256
267
default
V
getLongestMatch
(
int
[] input) {
268
return
getLongestMatch
(IntStream.of(input).iterator());
269
}
270
281
V
getLongestMatch
(PrimitiveIterator.OfInt input);
282
292
default
Iterator<V>
getAllMatches
(String input) {
293
return
getAllMatches
(input.codePoints().iterator());
294
}
295
306
default
Iterator<V>
getAllMatches
(
int
[] input) {
307
return
getAllMatches
(IntStream.of(input).iterator());
308
}
309
320
Iterator<V>
getAllMatches
(PrimitiveIterator.OfInt input);
321
}
org.wpilib.util.collections.PrefixMap
Definition
PrefixMap.java:43
org.wpilib.util.collections.PrefixMap.containsPrefix
default boolean containsPrefix(String prefix)
Definition
PrefixMap.java:183
org.wpilib.util.collections.PrefixMap.getShortestMatch
default V getShortestMatch(int[] input)
Definition
PrefixMap.java:228
org.wpilib.util.collections.PrefixMap.put
V put(String prefix, V value)
org.wpilib.util.collections.PrefixMap.isEmpty
default boolean isEmpty()
Definition
PrefixMap.java:58
org.wpilib.util.collections.PrefixMap.getAllMatches
default Iterator< V > getAllMatches(int[] input)
Definition
PrefixMap.java:306
org.wpilib.util.collections.PrefixMap.getLongestMatch
default V getLongestMatch(int[] input)
Definition
PrefixMap.java:267
org.wpilib.util.collections.PrefixMap.getLongestMatch
V getLongestMatch(PrimitiveIterator.OfInt input)
org.wpilib.util.collections.PrefixMap.putAll
default void putAll(Map<? extends String, ? extends V > prefixesAndValues)
Definition
PrefixMap.java:70
org.wpilib.util.collections.PrefixMap.getAllMatches
Iterator< V > getAllMatches(PrimitiveIterator.OfInt input)
org.wpilib.util.collections.PrefixMap.getShortestMatch
V getShortestMatch(PrimitiveIterator.OfInt input)
org.wpilib.util.collections.PrefixMap.getAllMatches
default Iterator< V > getAllMatches(String input)
Definition
PrefixMap.java:292
org.wpilib.util.collections.PrefixMap.getLongestMatch
default V getLongestMatch(String input)
Definition
PrefixMap.java:253
org.wpilib.util.collections.PrefixMap.getShortestMatch
default V getShortestMatch(String input)
Definition
PrefixMap.java:214
org.wpilib.util.collections.PrefixMap.containsPrefix
default boolean containsPrefix(int[] prefix)
Definition
PrefixMap.java:193
org.wpilib.util.collections.PrefixMap.size
int size()
org.wpilib.util.collections.PrefixMap.containsPrefix
boolean containsPrefix(PrimitiveIterator.OfInt prefix)
org.wpilib.util.collections.PrefixMap.clear
default void clear()
Definition
PrefixMap.java:172
org
wpilib
util
collections
PrefixMap.java
Generated by
1.18.0