blob: 16585de74ac85086e652a64a50a27a2b9e9bd3dd [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
jcc4a20a5f2015-04-30 15:43:39 +080018import static com.google.common.base.Preconditions.checkNotNull;
19import org.onosproject.core.DefaultGroupId;
wei wei89ddc322015-03-22 16:29:04 -050020import org.onosproject.net.AbstractDescription;
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
wei wei89ddc322015-03-22 16:29:04 -050041
42 /**
43 * Creates a tunnel description using the supplied information.
44 *
jcc4a20a5f2015-04-30 15:43:39 +080045 * @param id TunnelId
46 * @param src TunnelPoint source
47 * @param dst TunnelPoint destination
48 * @param type tunnel type
49 * @param groupId groupId
50 * @param producerName tunnel producer
51 * @param tunnelName tunnel name
wei wei89ddc322015-03-22 16:29:04 -050052 * @param annotations optional key/value annotations
53 */
jcc4a20a5f2015-04-30 15:43:39 +080054 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
55 TunnelEndPoint dst, Tunnel.Type type,
56 DefaultGroupId groupId,
57 ProviderId producerName,
58 TunnelName tunnelName,
59 SparseAnnotations... annotations) {
wei wei89ddc322015-03-22 16:29:04 -050060 super(annotations);
jcc4a20a5f2015-04-30 15:43:39 +080061 checkNotNull(producerName, "producerName cannot be null");
62 checkNotNull(src, "src cannot be null");
63 checkNotNull(dst, "dst cannot be null");
64 checkNotNull(type, "type cannot be null");
wei wei89ddc322015-03-22 16:29:04 -050065 this.tunnelId = id;
66 this.src = src;
67 this.dst = dst;
68 this.type = type;
jcc4a20a5f2015-04-30 15:43:39 +080069 this.groupId = groupId;
70 this.producerName = producerName;
71 this.tunnelName = tunnelName;
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
109 @Override
110 public String toString() {
111 return MoreObjects.toStringHelper(this)
112 .add("tunnelId", id())
113 .add("src", src())
114 .add("dst", dst())
115 .add("type", type())
jcc4a20a5f2015-04-30 15:43:39 +0800116 .add("tunnelName", tunnelName())
117 .add("producerName", producerName())
118 .add("groupId", groupId())
wei wei89ddc322015-03-22 16:29:04 -0500119 .toString();
120 }
121
122}