blob: 9f2b459d20d9d4958064911849547a1493ae95d5 [file] [log] [blame]
Jon Halld198b882016-05-18 16:44:40 -07001/*
Thomas Vachuskab6d31672018-07-27 17:03:46 -07002 * Copyright 2018-present Open Networking Foundation
Jon Halld198b882016-05-18 16:44:40 -07003 *
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 */
Thomas Vachuskab6d31672018-07-27 17:03:46 -070016package org.onosproject.store.atomix.primitives.impl;
Jon Halld198b882016-05-18 16:44:40 -070017
Jordan Halterman00e92da2018-05-22 23:05:52 -070018import java.util.Set;
19
Jon Halld198b882016-05-18 16:44:40 -070020import com.google.common.base.MoreObjects;
21import com.google.common.collect.ImmutableSet;
22import org.onosproject.cluster.NodeId;
23
Jon Halld198b882016-05-18 16:44:40 -070024import static com.google.common.base.Preconditions.checkNotNull;
25
26/**
27 * Describes a request for update events in an EventuallyConsistentMap.
28 */
29final class UpdateRequest<K> {
30
31 private final NodeId sender;
32 private final Set<K> keys;
33
34 /**
35 * Creates a new update request.
36 *
37 * @param sender the sender's node ID
38 * @param keys keys requested
39 */
40 public UpdateRequest(NodeId sender, Set<K> keys) {
41 this.sender = checkNotNull(sender);
42 this.keys = ImmutableSet.copyOf(keys);
43 }
44
45 /**
46 * Returns the sender's node ID.
47 *
48 * @return the sender's node ID
49 */
50 public NodeId sender() {
51 return sender;
52 }
53
54 /**
55 * Returns the keys.
56 *
57 * @return the keys
58 */
59 public Set<K> keys() {
60 return keys;
61 }
62
63 @Override
64 public String toString() {
65 return MoreObjects.toStringHelper(getClass())
66 .add("sender", sender)
67 .add("keys", keys())
68 .toString();
69 }
70
71 @SuppressWarnings("unused")
72 private UpdateRequest() {
73 this.sender = null;
74 this.keys = null;
75 }
76}