blob: 347021db7f461244bd56f63c248055e63b2898d4 [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 */
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070016package org.onosproject.incubator.net.tunnel;
wei wei89ddc322015-03-22 16:29:04 -050017
jcc4a20a5f2015-04-30 15:43:39 +080018import org.onosproject.core.DefaultGroupId;
wei wei89ddc322015-03-22 16:29:04 -050019import org.onosproject.net.AbstractDescription;
samuel7a5691a2015-05-23 00:36:32 +080020import org.onosproject.net.Path;
wei wei89ddc322015-03-22 16:29:04 -050021import org.onosproject.net.SparseAnnotations;
jcc4a20a5f2015-04-30 15:43:39 +080022import org.onosproject.net.provider.ProviderId;
23
24import com.google.common.base.MoreObjects;
wei wei89ddc322015-03-22 16:29:04 -050025
26/**
27 * Default implementation of immutable tunnel description entity.
28 */
29public class DefaultTunnelDescription extends AbstractDescription
30 implements TunnelDescription {
31
jcc4a20a5f2015-04-30 15:43:39 +080032 private final TunnelId tunnelId;
33 private final TunnelEndPoint src;
34 private final TunnelEndPoint dst;
wei wei89ddc322015-03-22 16:29:04 -050035 private final Tunnel.Type type;
jcc4a20a5f2015-04-30 15:43:39 +080036 private final DefaultGroupId groupId; // represent for a group flow table
37 // which a tunnel match up
38 // tunnel producer
39 private final ProviderId producerName; // tunnel producer name
40 private final TunnelName tunnelName; // name of a tunnel
samuel7a5691a2015-05-23 00:36:32 +080041 private final Path path;
wei wei89ddc322015-03-22 16:29:04 -050042
43 /**
44 * Creates a tunnel description using the supplied information.
45 *
jcc4a20a5f2015-04-30 15:43:39 +080046 * @param id TunnelId
47 * @param src TunnelPoint source
48 * @param dst TunnelPoint destination
49 * @param type tunnel type
50 * @param groupId groupId
51 * @param producerName tunnel producer
52 * @param tunnelName tunnel name
samuel7a5691a2015-05-23 00:36:32 +080053 * @param path the path of tunnel
wei wei89ddc322015-03-22 16:29:04 -050054 * @param annotations optional key/value annotations
55 */
jcc4a20a5f2015-04-30 15:43:39 +080056 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
57 TunnelEndPoint dst, Tunnel.Type type,
58 DefaultGroupId groupId,
59 ProviderId producerName,
60 TunnelName tunnelName,
samuel7a5691a2015-05-23 00:36:32 +080061 Path path,
jcc4a20a5f2015-04-30 15:43:39 +080062 SparseAnnotations... annotations) {
wei wei89ddc322015-03-22 16:29:04 -050063 super(annotations);
64 this.tunnelId = id;
65 this.src = src;
66 this.dst = dst;
67 this.type = type;
jcc4a20a5f2015-04-30 15:43:39 +080068 this.groupId = groupId;
69 this.producerName = producerName;
70 this.tunnelName = tunnelName;
samuel7a5691a2015-05-23 00:36:32 +080071 this.path = path;
wei wei89ddc322015-03-22 16:29:04 -050072 }
73
74 @Override
75 public TunnelId id() {
76 return tunnelId;
77 }
78
79 @Override
jcc4a20a5f2015-04-30 15:43:39 +080080 public TunnelEndPoint src() {
wei wei89ddc322015-03-22 16:29:04 -050081 return src;
82 }
83
84 @Override
jcc4a20a5f2015-04-30 15:43:39 +080085 public TunnelEndPoint dst() {
wei wei89ddc322015-03-22 16:29:04 -050086 return dst;
87 }
88
89 @Override
90 public Tunnel.Type type() {
91 return type;
92 }
93
94 @Override
jcc4a20a5f2015-04-30 15:43:39 +080095 public DefaultGroupId groupId() {
96 return groupId;
97 }
98
99 @Override
100 public ProviderId producerName() {
101 return producerName;
102 }
103
104 @Override
105 public TunnelName tunnelName() {
106 return tunnelName;
wei wei89ddc322015-03-22 16:29:04 -0500107 }
108
samuel7a5691a2015-05-23 00:36:32 +0800109
110 @Override
111 public Path path() {
112 return path;
113 }
114
wei wei89ddc322015-03-22 16:29:04 -0500115 @Override
116 public String toString() {
117 return MoreObjects.toStringHelper(this)
118 .add("tunnelId", id())
119 .add("src", src())
120 .add("dst", dst())
121 .add("type", type())
jcc4a20a5f2015-04-30 15:43:39 +0800122 .add("tunnelName", tunnelName())
123 .add("producerName", producerName())
124 .add("groupId", groupId())
samuel7a5691a2015-05-23 00:36:32 +0800125 .add("path", path)
wei wei89ddc322015-03-22 16:29:04 -0500126 .toString();
127 }
wei wei89ddc322015-03-22 16:29:04 -0500128}