Correct Spliterator characteristics
[yangtools.git] / third-party / triemap / src / main / java / org / opendaylight / yangtools / triemap / ImmutableEntrySet.java
1 /*
2  * (C) Copyright 2017 Pantheon Technologies, s.r.o. and others.
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  *     http://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 package org.opendaylight.yangtools.triemap;
17
18 import static org.opendaylight.yangtools.triemap.ImmutableTrieMap.unsupported;
19
20 import java.util.Collection;
21 import java.util.Iterator;
22 import java.util.Map.Entry;
23 import java.util.Spliterator;
24
25 /**
26  * {@link AbstractEntrySet} implementation guarding against attempts to mutate the underlying map.
27  *
28  * @author Robert Varga
29  *
30  * @param <K> the type of entry keys
31  * @param <V> the type of entry values
32  */
33 final class ImmutableEntrySet<K, V> extends AbstractEntrySet<K, V> {
34     ImmutableEntrySet(final TrieMap<K, V> map) {
35         super(map);
36     }
37
38     @Override
39     public void clear() {
40         throw unsupported();
41     }
42
43     @Override
44     public Iterator<Entry<K, V>> iterator() {
45         return map().immutableIterator();
46     }
47
48     @Override
49     @SuppressWarnings("checkstyle:parameterName")
50     public boolean remove(final Object o) {
51         throw unsupported();
52     }
53
54     @Override
55     @SuppressWarnings("checkstyle:parameterName")
56     public boolean removeAll(final Collection<?> c) {
57         throw unsupported();
58     }
59
60     @Override
61     @SuppressWarnings("checkstyle:parameterName")
62     public boolean retainAll(final Collection<?> c) {
63         throw unsupported();
64     }
65
66     @Override
67     int characteristics() {
68         return Spliterator.DISTINCT | Spliterator.IMMUTABLE | Spliterator.NONNULL;
69     }
70 }