blob: 3db4dce5d76ebb373b115639459d4e1d0f59b840 [file] [log] [blame]
Aaron Kruglikov61582a02016-09-06 13:18:58 -07001/*
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
17package org.onosproject.store.primitives.impl;
18
Jonathan Hart46bf89b2017-02-27 15:56:42 -080019import com.google.common.collect.Multiset;
20import org.onosproject.store.service.AsyncConsistentMultimap;
21import org.onosproject.store.service.MultimapEventListener;
22import org.onosproject.store.service.Versioned;
23
Jordan Halterman9bdc24f2017-04-19 23:45:12 -070024import java.util.Collection;
25import java.util.Map;
26import java.util.Set;
27import java.util.concurrent.CompletableFuture;
28
Jonathan Hart46bf89b2017-02-27 15:56:42 -080029import java.util.concurrent.Executor;
Aaron Kruglikov61582a02016-09-06 13:18:58 -070030
Aaron Kruglikov61582a02016-09-06 13:18:58 -070031/**
32 * {@code AsyncConsistentMultimap} that merely delegates control to
33 * another AsyncConsistentMultimap.
34 *
35 * @param <K> key type
36 * @param <V> value type
37 */
38public class DelegatingAsyncConsistentMultimap<K, V>
Jordan Halterman9bdc24f2017-04-19 23:45:12 -070039 extends DelegatingDistributedPrimitive implements AsyncConsistentMultimap<K, V> {
Aaron Kruglikov61582a02016-09-06 13:18:58 -070040
41 private final AsyncConsistentMultimap<K, V> delegateMap;
42
43 public DelegatingAsyncConsistentMultimap(
44 AsyncConsistentMultimap<K, V> delegateMap) {
Jordan Halterman9bdc24f2017-04-19 23:45:12 -070045 super(delegateMap);
46 this.delegateMap = delegateMap;
Aaron Kruglikov61582a02016-09-06 13:18:58 -070047 }
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 Hart46bf89b2017-02-27 15:56:42 -0800139 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 Kruglikov61582a02016-09-06 13:18:58 -0700149 public CompletableFuture<Map<K, Collection<V>>> asMap() {
150 return delegateMap.asMap();
151 }
Aaron Kruglikov61582a02016-09-06 13:18:58 -0700152}