blob: 868804ec88c325361a0ba07e958d2d434809ef6a [file] [log] [blame]
Aaron Kruglikovb4916d02015-09-08 16:22:25 -07001/*
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08002 * Copyright 2018-present Open Networking Foundation
Aaron Kruglikovb4916d02015-09-08 16:22:25 -07003 *
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 */
16
17package org.onosproject.incubator.net.tunnel;
18
19import com.google.common.annotations.Beta;
Jian Lib6d998e2016-02-29 11:41:18 -080020import org.onlab.util.Identifier;
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070021
22/**
23 * Representation of a Network Tunnel Id.
24 */
25@Beta
Jian Lib6d998e2016-02-29 11:41:18 -080026public final class NetworkTunnelId extends Identifier<Long> {
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070027 /**
28 * Creates an tunnel identifier from the specified tunnel.
29 *
30 * @param value long value
31 * @return tunnel identifier
32 */
33 public static NetworkTunnelId valueOf(long value) {
34 return new NetworkTunnelId(value);
35 }
36
37 public static NetworkTunnelId valueOf(String value) {
38 return new NetworkTunnelId(Long.parseLong(value));
39 }
40
41 /**
42 * Constructor for serializer.
43 */
44 NetworkTunnelId() {
Jian Lib6d998e2016-02-29 11:41:18 -080045 super(0L);
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070046 }
47
48 /**
49 * Constructs the ID corresponding to a given long value.
50 *
51 * @param value the underlying value of this ID
52 */
53 public NetworkTunnelId(long value) {
Jian Lib6d998e2016-02-29 11:41:18 -080054 super(value);
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070055 }
56
57 @Override
58 public String toString() {
Jian Lib6d998e2016-02-29 11:41:18 -080059 return "0x" + Long.toHexString(identifier);
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070060 }
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070061}