blob: 6faa846acc9fc65cea4ed455779b92ea278ee347 [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
Henry Yu4b4a7eb2016-11-09 20:07:53 -05003 *
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.tetopology.management.api.node;
17
18import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
19
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
24 * Representation of TE node event.
25 */
26public class TeNodeEventSubject implements TeTopologyEventSubject {
27 private final TeNodeKey key;
28 private final TeNode teNode;
29
30 /**
31 * Creates a TE node event.
32 *
33 * @param key the TE node global key
34 * @param teNode the TE node
35 */
36 public TeNodeEventSubject(TeNodeKey key, TeNode teNode) {
37 this.key = key;
38 this.teNode = teNode;
39 }
40
41 /**
42 * Returns the TE node global key.
43 *
44 * @return the key
45 */
46 public TeNodeKey key() {
47 return key;
48 }
49
50 /**
51 * Returns the TE node.
52 *
53 * @return the TE node
54 */
55 public TeNode teNode() {
56 return teNode;
57 }
58
59 @Override
60 public int hashCode() {
61 return Objects.hashCode(key, teNode);
62 }
63
64 @Override
65 public boolean equals(Object object) {
66 if (this == object) {
67 return true;
68 }
69 if (object instanceof TeNodeEventSubject) {
70 TeNodeEventSubject that = (TeNodeEventSubject) object;
71 return Objects.equal(key, that.key) &&
72 Objects.equal(teNode, that.teNode);
73 }
74 return false;
75 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(this)
80 .add("key", key)
81 .add("teNode", teNode)
82 .toString();
83 }
84}