blob: 310c607851983a317eab4c31df4bf826fe365a47 [file] [log] [blame]
Madan Jampanic27b6b22016-02-05 11:36:31 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Madan Jampanic27b6b22016-02-05 11:36:31 -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 */
16package org.onosproject.iptopology.api;
17
18import org.onosproject.net.AbstractModel;
19import org.onosproject.net.Annotations;
20import org.onosproject.net.provider.ProviderId;
21
22import java.util.Objects;
23
24import static com.google.common.base.MoreObjects.toStringHelper;
25
26/**
27 * This class provides Link identifier and link ted details.
28 */
29public class DefaultIpLink extends AbstractModel implements IpLink {
30
31 private final TerminationPoint src;
32 private final TerminationPoint dst;
33 private final IpLinkIdentifier linkIdentifier;
34 private final LinkTed linkTed;
35
36 /**
37 * Constructor to initialize its parameters.
38 *
39 * @param providerId provider identification
40 * @param src link source termination point
41 * @param dst link destination termination point
42 * @param linkIdentifier provides link identifier details
43 * @param linkTed provides link traffic engineering details
44 * @param annotations optional key/value annotations
45 */
46 public DefaultIpLink(ProviderId providerId, TerminationPoint src, TerminationPoint dst,
47 IpLinkIdentifier linkIdentifier, LinkTed linkTed,
48 Annotations... annotations) {
49 super(providerId, annotations);
50 this.src = src;
51 this.dst = dst;
52 this.linkIdentifier = linkIdentifier;
53 this.linkTed = linkTed;
54 }
55
56 @Override
57 public TerminationPoint src() {
58 return src;
59 }
60
61 @Override
62 public TerminationPoint dst() {
63 return dst;
64 }
65
66 @Override
67 public IpLinkIdentifier linkIdentifier() {
68 return linkIdentifier;
69 }
70
71 @Override
72 public LinkTed linkTed() {
73 return linkTed;
74 }
75
76 @Override
77 public int hashCode() {
78 return Objects.hash(src, dst, linkIdentifier, linkTed);
79 }
80
81 @Override
82 public boolean equals(Object obj) {
83 if (this == obj) {
84 return true;
85 }
86 if (obj instanceof DefaultIpLink) {
87 final DefaultIpLink other = (DefaultIpLink) obj;
88 return Objects.equals(this.src, other.src) &&
89 Objects.equals(this.dst, other.dst) &&
90 Objects.equals(this.linkIdentifier, other.linkIdentifier) &&
91 Objects.equals(this.linkTed, other.linkTed);
92 }
93 return false;
94 }
95
96 @Override
97 public String toString() {
98 return toStringHelper(this)
99 .omitNullValues()
100 .add("src", src)
101 .add("dst", dst)
102 .add("linkIdentifier", linkIdentifier)
103 .add("linkTed", linkTed)
104 .toString();
105 }
Satish Kf6d87cb2015-11-30 19:59:22 +0530106}