blob: 891eb65d9ab346a8d291bcd549353781844aa429 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.link;
tom4c6606f2014-09-07 11:11:21 -070017
alshabibdfc7afb2014-10-21 20:13:27 -070018import com.google.common.base.MoreObjects;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.net.AbstractDescription;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.Link;
22import org.onosproject.net.SparseAnnotations;
tom4c6606f2014-09-07 11:11:21 -070023
24/**
25 * Default implementation of immutable link description entity.
26 */
tomf5d85d42014-10-02 05:27:56 -070027public class DefaultLinkDescription extends AbstractDescription
28 implements LinkDescription {
tom4c6606f2014-09-07 11:11:21 -070029
tomeadbb462014-09-07 16:10:19 -070030 private final ConnectPoint src;
31 private final ConnectPoint dst;
32 private final Link.Type type;
tom4c6606f2014-09-07 11:11:21 -070033
34 /**
35 * Creates a link description using the supplied information.
36 *
Thomas Vachuska57126fe2014-11-11 17:13:24 -080037 * @param src link source
38 * @param dst link destination
39 * @param type link type
tomf5d85d42014-10-02 05:27:56 -070040 * @param annotations optional key/value annotations
tom4c6606f2014-09-07 11:11:21 -070041 */
tomf5d85d42014-10-02 05:27:56 -070042 public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst,
43 Link.Type type, SparseAnnotations... annotations) {
44 super(annotations);
tom4c6606f2014-09-07 11:11:21 -070045 this.src = src;
46 this.dst = dst;
tomeadbb462014-09-07 16:10:19 -070047 this.type = type;
tom4c6606f2014-09-07 11:11:21 -070048 }
49
50 @Override
51 public ConnectPoint src() {
52 return src;
53 }
54
55 @Override
56 public ConnectPoint dst() {
57 return dst;
58 }
59
tomeadbb462014-09-07 16:10:19 -070060 @Override
61 public Link.Type type() {
tomd176fc42014-09-08 00:12:30 -070062 return type;
tomeadbb462014-09-07 16:10:19 -070063 }
64
alshabibdfc7afb2014-10-21 20:13:27 -070065 @Override
66 public String toString() {
Thomas Vachuska57126fe2014-11-11 17:13:24 -080067 return MoreObjects.toStringHelper(this)
68 .add("src", src())
69 .add("dst", dst())
70 .add("type", type()).toString();
alshabibdfc7afb2014-10-21 20:13:27 -070071 }
72
tom4c6606f2014-09-07 11:11:21 -070073}