blob: e4c4d89352a68e2a5db213ca8058a49dab22cb8c [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 -070016
17package org.onosproject.incubator.net.tunnel;
wei wei89ddc322015-03-22 16:29:04 -050018
jcc4a20a5f2015-04-30 15:43:39 +080019import static com.google.common.base.Preconditions.checkNotNull;
20import org.onosproject.core.DefaultGroupId;
wei wei89ddc322015-03-22 16:29:04 -050021import org.onosproject.net.AbstractDescription;
wei wei89ddc322015-03-22 16:29:04 -050022import org.onosproject.net.SparseAnnotations;
jcc4a20a5f2015-04-30 15:43:39 +080023import org.onosproject.net.provider.ProviderId;
24
25import com.google.common.base.MoreObjects;
wei wei89ddc322015-03-22 16:29:04 -050026
27/**
28 * Default implementation of immutable tunnel description entity.
29 */
30public class DefaultTunnelDescription extends AbstractDescription
31 implements TunnelDescription {
32
jcc4a20a5f2015-04-30 15:43:39 +080033 private final TunnelId tunnelId;
34 private final TunnelEndPoint src;
35 private final TunnelEndPoint dst;
wei wei89ddc322015-03-22 16:29:04 -050036 private final Tunnel.Type type;
jcc4a20a5f2015-04-30 15:43:39 +080037 private final DefaultGroupId groupId; // represent for a group flow table
38 // which a tunnel match up
39 // tunnel producer
40 private final ProviderId producerName; // tunnel producer name
41 private final TunnelName tunnelName; // name of a tunnel
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
wei wei89ddc322015-03-22 16:29:04 -050053 * @param annotations optional key/value annotations
54 */
jcc4a20a5f2015-04-30 15:43:39 +080055 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
56 TunnelEndPoint dst, Tunnel.Type type,
57 DefaultGroupId groupId,
58 ProviderId producerName,
59 TunnelName tunnelName,
60 SparseAnnotations... annotations) {
wei wei89ddc322015-03-22 16:29:04 -050061 super(annotations);
jcc4a20a5f2015-04-30 15:43:39 +080062 checkNotNull(producerName, "producerName cannot be null");
63 checkNotNull(src, "src cannot be null");
64 checkNotNull(dst, "dst cannot be null");
65 checkNotNull(type, "type cannot be null");
wei wei89ddc322015-03-22 16:29:04 -050066 this.tunnelId = id;
67 this.src = src;
68 this.dst = dst;
69 this.type = type;
jcc4a20a5f2015-04-30 15:43:39 +080070 this.groupId = groupId;
71 this.producerName = producerName;
72 this.tunnelName = tunnelName;
wei wei89ddc322015-03-22 16:29:04 -050073 }
74
75 @Override
76 public TunnelId id() {
77 return tunnelId;
78 }
79
80 @Override
jcc4a20a5f2015-04-30 15:43:39 +080081 public TunnelEndPoint src() {
wei wei89ddc322015-03-22 16:29:04 -050082 return src;
83 }
84
85 @Override
jcc4a20a5f2015-04-30 15:43:39 +080086 public TunnelEndPoint dst() {
wei wei89ddc322015-03-22 16:29:04 -050087 return dst;
88 }
89
90 @Override
91 public Tunnel.Type type() {
92 return type;
93 }
94
95 @Override
jcc4a20a5f2015-04-30 15:43:39 +080096 public DefaultGroupId groupId() {
97 return groupId;
98 }
99
100 @Override
101 public ProviderId producerName() {
102 return producerName;
103 }
104
105 @Override
106 public TunnelName tunnelName() {
107 return tunnelName;
wei wei89ddc322015-03-22 16:29:04 -0500108 }
109
110 @Override
111 public String toString() {
112 return MoreObjects.toStringHelper(this)
113 .add("tunnelId", id())
114 .add("src", src())
115 .add("dst", dst())
116 .add("type", type())
jcc4a20a5f2015-04-30 15:43:39 +0800117 .add("tunnelName", tunnelName())
118 .add("producerName", producerName())
119 .add("groupId", groupId())
wei wei89ddc322015-03-22 16:29:04 -0500120 .toString();
121 }
122
123}