blob: 720527b60d31df2efa78ad3db0ac7edfc0179a20 [file] [log] [blame]
Jonathan Hartf9108232015-02-02 16:37:35 -08001/*
2 * Copyright 2015 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 */
16package org.onosproject.store.impl;
17
18import com.google.common.collect.ImmutableList;
19import org.onosproject.store.Timestamp;
20
21import java.util.List;
22
23import static com.google.common.base.Preconditions.checkNotNull;
24
25/**
26 * Internal inter-instance event used by EventuallyConsistentMap for REMOVE
27 * events.
28 */
29final class InternalRemoveEvent<K> {
30 private final List<RemoveEntry<K>> entries;
31
32 /**
33 * Creates a remove event for a single key.
34 *
35 * @param key key the event concerns
36 * @param timestamp timestamp of the event
37 */
38 public InternalRemoveEvent(K key, Timestamp timestamp) {
39 entries = ImmutableList.of(new RemoveEntry<>(key, timestamp));
40 }
41
42 /**
43 * Creates a remove event for multiple keys.
44 *
45 * @param entries list of remove entries to send an event for
46 */
47 public InternalRemoveEvent(List<RemoveEntry<K>> entries) {
48 this.entries = checkNotNull(entries);
49 }
50
51 // Needed for serialization.
52 @SuppressWarnings("unused")
53 private InternalRemoveEvent() {
54 entries = null;
55 }
56
57 /**
58 * Returns the list of remove entries this event concerns.
59 *
60 * @return list of remove entries
61 */
62 public List<RemoveEntry<K>> entries() {
63 return entries;
64 }
65}