Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | |
| 17 | package org.onosproject.store.primitives.impl; |
| 18 | |
Jonathan Hart | 46bf89b | 2017-02-27 15:56:42 -0800 | [diff] [blame] | 19 | import com.google.common.collect.Multiset; |
| 20 | import org.onosproject.store.service.AsyncConsistentMultimap; |
| 21 | import org.onosproject.store.service.MultimapEventListener; |
| 22 | import org.onosproject.store.service.Versioned; |
| 23 | |
Jordan Halterman | 9bdc24f | 2017-04-19 23:45:12 -0700 | [diff] [blame] | 24 | import java.util.Collection; |
| 25 | import java.util.Map; |
| 26 | import java.util.Set; |
| 27 | import java.util.concurrent.CompletableFuture; |
| 28 | |
Jonathan Hart | 46bf89b | 2017-02-27 15:56:42 -0800 | [diff] [blame] | 29 | import java.util.concurrent.Executor; |
Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 30 | |
Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 31 | /** |
| 32 | * {@code AsyncConsistentMultimap} that merely delegates control to |
| 33 | * another AsyncConsistentMultimap. |
| 34 | * |
| 35 | * @param <K> key type |
| 36 | * @param <V> value type |
| 37 | */ |
| 38 | public class DelegatingAsyncConsistentMultimap<K, V> |
Jordan Halterman | 9bdc24f | 2017-04-19 23:45:12 -0700 | [diff] [blame] | 39 | extends DelegatingDistributedPrimitive implements AsyncConsistentMultimap<K, V> { |
Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 40 | |
| 41 | private final AsyncConsistentMultimap<K, V> delegateMap; |
| 42 | |
| 43 | public DelegatingAsyncConsistentMultimap( |
| 44 | AsyncConsistentMultimap<K, V> delegateMap) { |
Jordan Halterman | 9bdc24f | 2017-04-19 23:45:12 -0700 | [diff] [blame] | 45 | super(delegateMap); |
| 46 | this.delegateMap = delegateMap; |
Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public CompletableFuture<Integer> size() { |
| 51 | return delegateMap.size(); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public CompletableFuture<Boolean> isEmpty() { |
| 56 | return delegateMap.isEmpty(); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public CompletableFuture<Boolean> containsKey(K key) { |
| 61 | return delegateMap.containsKey(key); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public CompletableFuture<Boolean> containsValue(V value) { |
| 66 | return delegateMap.containsValue(value); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public CompletableFuture<Boolean> containsEntry(K key, V value) { |
| 71 | return delegateMap.containsEntry(key, value); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public CompletableFuture<Boolean> put(K key, V value) { |
| 76 | return delegateMap.put(key, value); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public CompletableFuture<Boolean> remove(K key, V value) { |
| 81 | return delegateMap.remove(key, value); |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public CompletableFuture<Boolean> removeAll( |
| 86 | K key, Collection<? extends V> values) { |
| 87 | return delegateMap.removeAll(key, values); |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public CompletableFuture<Versioned<Collection<? extends V>>> |
| 92 | removeAll(K key) { |
| 93 | return delegateMap.removeAll(key); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public CompletableFuture<Boolean> putAll( |
| 98 | K key, Collection<? extends V> values) { |
| 99 | return delegateMap.putAll(key, values); |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public CompletableFuture<Versioned<Collection<? extends V>>> |
| 104 | replaceValues(K key, Collection<V> values) { |
| 105 | return delegateMap.replaceValues(key, values); |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public CompletableFuture<Void> clear() { |
| 110 | return delegateMap.clear(); |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public CompletableFuture<Versioned<Collection<? extends V>>> get(K key) { |
| 115 | return delegateMap.get(key); |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public CompletableFuture<Set<K>> keySet() { |
| 120 | return delegateMap.keySet(); |
| 121 | } |
| 122 | |
| 123 | @Override |
| 124 | public CompletableFuture<Multiset<K>> keys() { |
| 125 | return delegateMap.keys(); |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public CompletableFuture<Multiset<V>> values() { |
| 130 | return delegateMap.values(); |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public CompletableFuture<Collection<Map.Entry<K, V>>> entries() { |
| 135 | return delegateMap.entries(); |
| 136 | } |
| 137 | |
| 138 | @Override |
Jonathan Hart | 46bf89b | 2017-02-27 15:56:42 -0800 | [diff] [blame] | 139 | public CompletableFuture<Void> addListener(MultimapEventListener<K, V> listener, Executor executor) { |
| 140 | return delegateMap.addListener(listener, executor); |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public CompletableFuture<Void> removeListener(MultimapEventListener<K, V> listener) { |
| 145 | return delegateMap.removeListener(listener); |
| 146 | } |
| 147 | |
| 148 | @Override |
Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 149 | public CompletableFuture<Map<K, Collection<V>>> asMap() { |
| 150 | return delegateMap.asMap(); |
| 151 | } |
Aaron Kruglikov | 61582a0 | 2016-09-06 13:18:58 -0700 | [diff] [blame] | 152 | } |