blob: e847da48ebb523ad7111eb74c672fa31fabe629f [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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.tetopology.management.api.link;
17
18import org.onosproject.tetopology.management.api.KeyId;
19
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
24 * Representation of an external domain link.
25 */
26public class ExternalDomain {
27 private final KeyId remoteTeNodeId;
28 private final KeyId remoteTeLinkTpId;
29 private final long plugId;
30
31 /**
32 * Creates an instance of ExternalDomain.
33 *
34 * @param remoteTeNodeId remote TE node identifier
35 * @param remoteTeLinkTpId remote TE link termination point identifier
36 * @param plugId global plug id
37 */
38 public ExternalDomain(KeyId remoteTeNodeId, KeyId remoteTeLinkTpId, long plugId) {
39 this.remoteTeNodeId = remoteTeNodeId;
40 this.remoteTeLinkTpId = remoteTeLinkTpId;
41 this.plugId = plugId;
42 }
43
44 /**
45 * Creates an instance of ExternalDomain with remote TE node and tp.
46 *
47 * @param remoteTeNodeId remote TE node identifier
48 * @param remoteTeLinkTpId remote TE link termination point identifier
49 */
50 public ExternalDomain(KeyId remoteTeNodeId, KeyId remoteTeLinkTpId) {
51 this.remoteTeNodeId = remoteTeNodeId;
52 this.remoteTeLinkTpId = remoteTeLinkTpId;
53 this.plugId = 0L;
54 }
55
56 /**
57 * Creates an instance of ExternalDomain with plugId.
58 *
59 * @param plugId global plug id
60 */
61 public ExternalDomain(long plugId) {
62 this.remoteTeNodeId = null;
63 this.remoteTeLinkTpId = null;
64 this.plugId = plugId;
65 }
66
67 /**
68 * Returns the remote TeNode Id.
69 *
70 * @return value of the remote TE node identifier
71 */
72 public KeyId remoteTeNodeId() {
73 return remoteTeNodeId;
74 }
75
76 /**
77 * Returns the remote TeLink TpId.
78 *
79 * @return value of the remote TE link identifier
80 */
81 public KeyId remoteTeLinkTpId() {
82 return remoteTeLinkTpId;
83 }
84
85 /**
86 * Returns the plugId.
87 *
88 * @return value of the global plug id
89 */
90 public long plugId() {
91 return plugId;
92 }
93
94 @Override
95 public int hashCode() {
96 return Objects.hashCode(remoteTeNodeId, remoteTeLinkTpId, remoteTeLinkTpId);
97 }
98
99 @Override
100 public boolean equals(Object object) {
101 if (this == object) {
102 return true;
103 }
104 if (object instanceof ExternalDomain) {
105 ExternalDomain that = (ExternalDomain) object;
106 return Objects.equal(this.remoteTeNodeId, that.remoteTeNodeId) &&
107 Objects.equal(this.remoteTeLinkTpId, that.remoteTeLinkTpId) &&
108 Objects.equal(this.remoteTeLinkTpId, that.remoteTeLinkTpId);
109 }
110 return false;
111 }
112
113 @Override
114 public String toString() {
115 return MoreObjects.toStringHelper(this)
116 .add("remoteTeNodeId", remoteTeNodeId)
117 .add("remoteTeLinkTpId", remoteTeLinkTpId)
118 .add("remoteTeLinkTpId", remoteTeLinkTpId)
119 .toString();
120 }
121}