blob: fd38e646a39281f03f6903e9e15e1945297a9ee5 [file] [log] [blame]
Jonathan Hartdb3af892015-01-26 13:19:07 -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
18/**
19 * Event object signalling that the map was modified.
20 */
21public class EventuallyConsistentMapEvent<K, V> {
22
23 public enum Type {
24 PUT,
25 REMOVE
26 }
27
28 private final Type type;
29 private final K key;
30 private final V value;
31
32 /**
33 * Creates a new event object.
34 *
35 * @param type the type of the event
36 * @param key the key the event concerns
37 * @param value the value related to the key, or null for remove events
38 */
39 public EventuallyConsistentMapEvent(Type type, K key, V value) {
40 this.type = type;
41 this.key = key;
42 this.value = value;
43 }
44
45 /**
46 * Returns the type of the event.
47 *
48 * @return the type of the event
49 */
50 public Type type() {
51 return type;
52 }
53
54 /**
55 * Returns the key this event concerns.
56 *
57 * @return the key
58 */
59 public K key() {
60 return key;
61 }
62
63 /**
64 * Returns the value associated with this event.
65 *
66 * @return the value, or null if the event was REMOVE
67 */
68 public V value() {
69 return value;
70 }
71}