Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.link; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 17 | |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.net.AbstractDescription; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.Link; |
| 22 | import org.onosproject.net.SparseAnnotations; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Default implementation of immutable link description entity. |
| 26 | */ |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 27 | public class DefaultLinkDescription extends AbstractDescription |
| 28 | implements LinkDescription { |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 29 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 30 | private final ConnectPoint src; |
| 31 | private final ConnectPoint dst; |
| 32 | private final Link.Type type; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Creates a link description using the supplied information. |
| 36 | * |
Thomas Vachuska | 57126fe | 2014-11-11 17:13:24 -0800 | [diff] [blame] | 37 | * @param src link source |
| 38 | * @param dst link destination |
| 39 | * @param type link type |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 40 | * @param annotations optional key/value annotations |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 41 | */ |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 42 | public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst, |
| 43 | Link.Type type, SparseAnnotations... annotations) { |
| 44 | super(annotations); |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 45 | this.src = src; |
| 46 | this.dst = dst; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 47 | this.type = type; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public ConnectPoint src() { |
| 52 | return src; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public ConnectPoint dst() { |
| 57 | return dst; |
| 58 | } |
| 59 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 60 | @Override |
| 61 | public Link.Type type() { |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 62 | return type; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 63 | } |
| 64 | |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 65 | @Override |
| 66 | public String toString() { |
Thomas Vachuska | 57126fe | 2014-11-11 17:13:24 -0800 | [diff] [blame] | 67 | return MoreObjects.toStringHelper(this) |
| 68 | .add("src", src()) |
| 69 | .add("dst", dst()) |
| 70 | .add("type", type()).toString(); |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 71 | } |
| 72 | |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 73 | } |