blob: c9a5450fb583fae9bf724839b5452ec258aa928e [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright 2011, Big Switch Networks, Inc.
3* Originally created by David Erickson, Stanford University
4*
5* Licensed under the Apache License, Version 2.0 (the "License"); you may
6* not use this file except in compliance with the License. You may obtain
7* a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14* License for the specific language governing permissions and limitations
15* under the License.
16**/
17
18package net.floodlightcontroller.storage;
19
20import java.util.Set;
21
22public class StorageSourceNotification {
23
24 public enum Action { MODIFY, DELETE };
25
26 private String tableName;
27 private Action action;
28 private Set<Object> keys;
29
30 public StorageSourceNotification() {
31 }
32
33 public StorageSourceNotification(String tableName, Action action, Set<Object> keys) {
34 this.tableName = tableName;
35 this.action = action;
36 this.keys = keys;
37 }
38
39 public String getTableName() {
40 return tableName;
41 }
42
43 public Action getAction() {
44 return action;
45 }
46
47 public Set<Object> getKeys() {
48 return keys;
49 }
50
51 public void setTableName(String tableName) {
52 this.tableName = tableName;
53 }
54
55 public void setAction(Action action) {
56 this.action = action;
57 }
58
59 public void setKeys(Set<Object> keys) {
60 this.keys = keys;
61 }
62
63 /* (non-Javadoc)
64 * @see java.lang.Object#hashCode()
65 */
66 @Override
67 public int hashCode() {
68 final int prime = 7867;
69 int result = 1;
70 result = prime * result + tableName.hashCode();
71 result = prime * result + action.hashCode();
72 result = prime * result + keys.hashCode();
73 return result;
74 }
75
76 @Override
77 public boolean equals(Object obj) {
78 if (this == obj)
79 return true;
80 if (obj == null)
81 return false;
82 if (!(obj instanceof StorageSourceNotification))
83 return false;
84 StorageSourceNotification other = (StorageSourceNotification) obj;
85 if (tableName == null) {
86 if (other.tableName != null)
87 return false;
88 } else if (!tableName.equals(other.tableName))
89 return false;
90 if (action == null) {
91 if (other.action != null)
92 return false;
93 } else if (action != other.action)
94 return false;
95 if (keys == null) {
96 if (other.keys != null)
97 return false;
98 } else if (!keys.equals(other.keys))
99 return false;
100 return true;
101 }
102
103 @Override
104 public String toString() {
105 return ("StorageNotification[table=" + tableName + "; action=" +
106 action.toString() + "; keys=" + keys.toString() + "]");
107 }
108}