blob: 432f4c6ccd3e38d56f27a73adf044507b8a09eaf [file] [log] [blame]
wei wei89ddc322015-03-22 16:29:04 -05001/*
2 * Copyright 2015 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.net.tunnel;
17
18import com.google.common.base.MoreObjects;
19
20import org.onosproject.net.AbstractDescription;
21import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.SparseAnnotations;
23
24/**
25 * Default implementation of immutable tunnel description entity.
26 */
27public class DefaultTunnelDescription extends AbstractDescription
28 implements TunnelDescription {
29
30 private final TunnelId tunnelId;
31 private final ConnectPoint src;
32 private final ConnectPoint dst;
33 private final Tunnel.Type type;
34 private final boolean isBidirectional;
35
36 /**
37 * Creates a tunnel description using the supplied information.
38 *
39 * @param id TunnelId
40 * @param src ConnectPoint source
41 * @param dst ConnectPoint destination
42 * @param type tunnel type
43 * @param isBidirectional boolean
44 * @param annotations optional key/value annotations
45 */
46 public DefaultTunnelDescription(TunnelId id, ConnectPoint src, ConnectPoint dst,
47 Tunnel.Type type, boolean isBidirectional,
48 SparseAnnotations... annotations) {
49 super(annotations);
50 this.tunnelId = id;
51 this.src = src;
52 this.dst = dst;
53 this.type = type;
54 this.isBidirectional = isBidirectional;
55 }
56
57 @Override
58 public TunnelId id() {
59 return tunnelId;
60 }
61
62 @Override
63 public ConnectPoint src() {
64 return src;
65 }
66
67 @Override
68 public ConnectPoint dst() {
69 return dst;
70 }
71
72 @Override
73 public Tunnel.Type type() {
74 return type;
75 }
76
77 @Override
78 public boolean isBidirectional() {
79 return isBidirectional;
80 }
81
82 @Override
83 public String toString() {
84 return MoreObjects.toStringHelper(this)
85 .add("tunnelId", id())
86 .add("src", src())
87 .add("dst", dst())
88 .add("type", type())
89 .add("isBidirectional", isBidirectional())
90 .toString();
91 }
92
93}