blob: 716237b75c332c37deffc0c0bd1db11ae606526b [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.base.MoreObjects;
19import org.onosproject.store.Timestamp;
20
21import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Describes a single remove event in an EventuallyConsistentMap.
25 */
26final class RemoveEntry<K> {
27 private final K key;
28 private final Timestamp timestamp;
29
30 /**
31 * Creates a new remove entry.
32 *
33 * @param key key of the entry
34 * @param timestamp timestamp of the remove event
35 */
36 public RemoveEntry(K key, Timestamp timestamp) {
37 this.key = checkNotNull(key);
38 this.timestamp = checkNotNull(timestamp);
39 }
40
41 // Needed for serialization.
42 @SuppressWarnings("unused")
43 private RemoveEntry() {
44 this.key = null;
45 this.timestamp = null;
46 }
47
48 /**
49 * Returns the key of the entry.
50 *
51 * @return the key
52 */
53 public K key() {
54 return key;
55 }
56
57 /**
58 * Returns the timestamp of the event.
59 *
60 * @return the timestamp
61 */
62 public Timestamp timestamp() {
63 return timestamp;
64 }
65
66 @Override
67 public String toString() {
68 return MoreObjects.toStringHelper(getClass())
69 .add("key", key)
70 .add("timestamp", timestamp)
71 .toString();
72 }
73}