blob: 4a3b46d289aa8410d5e599d21695f9ef2d9a116a [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
2 * Copyright 2014 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.iptopology.api.link;
17
18import com.google.common.base.MoreObjects;
19import org.onosproject.iptopology.api.IpLinkIdentifier;
20import org.onosproject.iptopology.api.LinkTed;
21import org.onosproject.iptopology.api.TerminationPoint;
22import org.onosproject.net.AbstractDescription;
23import org.onosproject.net.SparseAnnotations;
24
25/**
26 * Default implementation of immutable ip link description entity.
27 */
28public class DefaultIpLinkDescription extends AbstractDescription
29 implements IpLinkDescription {
30
31 private final TerminationPoint src;
32 private final TerminationPoint dst;
33 private final IpLinkIdentifier linkIdentifier;
34 private final LinkTed linkTed;
35
36 /**
37 * Creates an ip link description using the supplied information.
38 *
39 * @param src link source
40 * @param dst link destination
41 * @param linkIdentifier link identifier
42 * @param linkTed link traffic engineering parameters
43 * @param annotations optional key/value annotations
44 */
45 public DefaultIpLinkDescription(TerminationPoint src, TerminationPoint dst,
46 IpLinkIdentifier linkIdentifier, LinkTed linkTed,
47 SparseAnnotations... annotations) {
48 super(annotations);
49 this.src = src;
50 this.dst = dst;
51 this.linkIdentifier = linkIdentifier;
52 this.linkTed = linkTed;
53 }
54
55 /**
56 * Creates an ip link description using the supplied information.
57 *
58 * @param base IpLinkDescription to basic information
59 * @param annotations optional key/value annotations
60 */
61 public DefaultIpLinkDescription(IpLinkDescription base, SparseAnnotations... annotations) {
62 this(base.src(), base.dst(), base.linkIdentifier(),
63 base.linkTed(), annotations);
64 }
65
66 @Override
67 public TerminationPoint src() {
68 return src;
69 }
70
71 @Override
72 public TerminationPoint dst() {
73 return dst;
74 }
75
76 @Override
77 public IpLinkIdentifier linkIdentifier() {
78 return linkIdentifier;
79 }
80
81 @Override
82 public LinkTed linkTed() {
83 return linkTed; }
84
85 @Override
86 public String toString() {
87 return MoreObjects.toStringHelper(this)
88 .add("src", src())
89 .add("dst", dst())
90 .add("linkIdentifier", linkIdentifier())
91 .add("linkTed", linkTed())
92 .toString();
93 }
94
95}