blob: c8aed143304b1e6c077be6a9399a8eab3ef63d64 [file] [log] [blame]
tony-liuaff59a72016-10-21 15:41:46 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
tony-liuaff59a72016-10-21 15:41:46 +08003 *
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 */
16
17package org.onosproject.tetunnel.api.tunnel;
18
19import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
20import org.onosproject.tetopology.management.api.node.TeNodeKey;
21import org.onosproject.tetopology.management.api.node.TtpKey;
22import java.util.Objects;
23import static com.google.common.base.MoreObjects.toStringHelper;
24
25/**
26 * TE tunnel endpoint implementation.
27 */
28public class TeTunnelEndpoint implements TunnelEndPoint {
29
30 private final TeNodeKey teNodeKey;
31 private final TtpKey ttpKey;
32
33 /**
34 * Creates a TE tunnel end point instance with supplied information.
35 *
36 * @param teNodeKey key of the TE node of this end point
37 * @param ttpKey key of the TE termination point of this end point
38 */
39 public TeTunnelEndpoint(TeNodeKey teNodeKey, TtpKey ttpKey) {
40 this.teNodeKey = teNodeKey;
41 this.ttpKey = ttpKey;
42 }
43
44 /**
45 * Returns key of the TE node of this end point.
46 *
47 * @return key of corresponding TE node
48 */
49 public TeNodeKey teNodeKey() {
50 return teNodeKey;
51 }
52
53 /**
54 * Returns key of the TE termination point of this end point.
55 *
56 * @return key of corresponding TE termination point
57 */
58 public TtpKey ttpKey() {
59 return ttpKey;
60 }
61
62 @Override
63 public int hashCode() {
64 return Objects.hash(teNodeKey, ttpKey);
65 }
66
67 @Override
68 public boolean equals(Object obj) {
69 if (this == obj) {
70 return true;
71 }
72 if (obj instanceof TeTunnelEndpoint) {
73 final TeTunnelEndpoint other = (TeTunnelEndpoint) obj;
74 return Objects.equals(this.teNodeKey, other.teNodeKey) &&
75 Objects.equals(this.ttpKey, other.ttpKey);
76 }
77 return false;
78 }
79
80 @Override
81 public String toString() {
82 return toStringHelper(this)
83 .add("teNodeKey", teNodeKey)
84 .add("ttpKey", ttpKey)
85 .toString();
86 }
87}