blob: 9e1115234a94ef1b01914257b54a2ac238086c89 [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
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 com.google.common.base.MoreObjects;
19import com.google.common.base.Objects;
20
21/**
22 * Representation of an external domain link.
23 */
24public class ExternalLink {
25 private final TeLinkTpGlobalKey externalLinkKey;
26 private final Long plugId;
27
28 /**
29 * Creates an instance of an external domain link.
30 *
31 * @param externalLinkKey external TE link key
32 * @param plugId global plug identifier
33 */
34 public ExternalLink(TeLinkTpGlobalKey externalLinkKey, long plugId) {
35 this.externalLinkKey = externalLinkKey;
36 this.plugId = plugId;
37 }
38
39 /**
40 * Returns the external TE link key.
41 *
42 * @return the externalLinkKey
43 */
44 public TeLinkTpGlobalKey externalLinkKey() {
45 return externalLinkKey;
46 }
47
48 /**
49 * Returns the global plug identifier.
50 *
51 * @return value of the global plug id
52 */
53 public Long plugId() {
54 return plugId;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hashCode(externalLinkKey, plugId);
60 }
61
62 @Override
63 public boolean equals(Object object) {
64 if (this == object) {
65 return true;
66 }
67 if (object instanceof ExternalLink) {
68 ExternalLink that = (ExternalLink) object;
69 return Objects.equal(externalLinkKey, that.externalLinkKey) &&
70 Objects.equal(plugId, that.plugId);
71 }
72 return false;
73 }
74
75 @Override
76 public String toString() {
77 return MoreObjects.toStringHelper(this)
78 .add("externalLinkKey", externalLinkKey)
79 .add("plugId", plugId)
80 .toString();
81 }
82}