2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onosproject.segmentrouting;
19 import java.util.List;
20 import java.util.Objects;
22 import static com.google.common.base.Preconditions.checkNotNull;
27 public class DefaultTunnel implements Tunnel {
29 private final String id;
30 private final List<Integer> labelIds;
33 private boolean allowedToRemoveGroup;
36 * Creates a Tunnel reference.
38 * @param tid Tunnel ID
39 * @param labelIds Label stack of the tunnel
41 public DefaultTunnel(String tid, List<Integer> labelIds) {
42 this.id = checkNotNull(tid);
43 this.labelIds = labelIds;
44 //TODO: need to register the class in Kryo for this
45 //this.labelIds = Collections.unmodifiableList(labelIds);
50 * Creates a new DefaultTunnel reference using the tunnel reference.
52 * @param tunnel DefaultTunnel reference
54 public DefaultTunnel(DefaultTunnel tunnel) {
56 this.labelIds = tunnel.labelIds;
57 this.groupId = tunnel.groupId;
66 public List<Integer> labelIds() {
71 public int groupId() {
76 public void setGroupId(int id) {
81 public boolean equals(Object o) {
86 if (o instanceof DefaultTunnel) {
87 DefaultTunnel tunnel = (DefaultTunnel) o;
88 // We compare only the tunnel paths.
89 if (tunnel.labelIds.equals(this.labelIds)) {
98 public int hashCode() {
99 return Objects.hash(labelIds);
103 public boolean isAllowedToRemoveGroup() {
104 return this.allowedToRemoveGroup;
108 public void allowToRemoveGroup(boolean b) {
109 this.allowedToRemoveGroup = b;