blob: 57965aa2aade7f531c16c2e44e81a8c5691f6157 [file] [log] [blame]
samuel8d6b0a92015-07-11 13:22:57 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
samuel8d6b0a92015-07-11 13:22:57 +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.net.behaviour;
17
18import org.onosproject.net.AbstractDescription;
19import org.onosproject.net.SparseAnnotations;
20
21import com.google.common.annotations.Beta;
22import com.google.common.base.MoreObjects;
23
24/**
25 * Default implementation of immutable tunnel description entity.
26 */
27@Beta
28public class DefaultTunnelDescription extends AbstractDescription
29 implements TunnelDescription {
30
31 private final TunnelEndPoint src;
32 private final TunnelEndPoint dst;
33 private final Type type;
34 // which a tunnel match up
35 // tunnel producer
36 private final TunnelName tunnelName; // name of a tunnel
37
38 /**
39 * Creates a tunnel description using the supplied information.
40 *
41 * @param src TunnelPoint source
42 * @param dst TunnelPoint destination
43 * @param type tunnel type
44 * @param tunnelName tunnel name
45 * @param annotations optional key/value annotations
46 */
47 public DefaultTunnelDescription(TunnelEndPoint src,
48 TunnelEndPoint dst, Type type,
49 TunnelName tunnelName,
50 SparseAnnotations... annotations) {
51 super(annotations);
52 this.src = src;
53 this.dst = dst;
54 this.type = type;
55 this.tunnelName = tunnelName;
56 }
57
58 @Override
59 public TunnelEndPoint src() {
60 return src;
61 }
62
63 @Override
64 public TunnelEndPoint dst() {
65 return dst;
66 }
67
68 @Override
69 public Type type() {
70 return type;
71 }
72
73 @Override
74 public TunnelName tunnelName() {
75 return tunnelName;
76 }
77
78 @Override
79 public String toString() {
80 return MoreObjects.toStringHelper(this)
81 .add("src", src())
82 .add("dst", dst())
83 .add("type", type())
84 .add("tunnelName", tunnelName())
85 .toString();
86 }
87}