blob: a06ab3aac48bdb222c86b2b10d36b43647bb4cd6 [file] [log] [blame]
wei wei89ddc322015-03-22 16:29:04 -05001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
wei wei89ddc322015-03-22 16:29:04 -05003 *
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
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040019import com.google.common.annotations.Beta;
Jian Lib6d998e2016-02-29 11:41:18 -080020import org.onlab.util.Identifier;
wei wei89ddc322015-03-22 16:29:04 -050021
22/**
23 * Representation of a Tunnel Id.
24 */
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040025@Beta
Jian Lib6d998e2016-02-29 11:41:18 -080026public final class TunnelId extends Identifier<Long> {
wei wei89ddc322015-03-22 16:29:04 -050027 /**
28 * Creates an tunnel identifier from the specified tunnel.
29 *
30 * @param value long value
31 * @return tunnel identifier
32 */
33 public static TunnelId valueOf(long value) {
34 return new TunnelId(value);
35 }
36
37 public static TunnelId valueOf(String value) {
samuel7a5691a2015-05-23 00:36:32 +080038 return new TunnelId(Long.parseLong(value));
wei wei89ddc322015-03-22 16:29:04 -050039 }
40
41 /**
42 * Constructor for serializer.
43 */
44 TunnelId() {
Jian Lib6d998e2016-02-29 11:41:18 -080045 super(0L);
wei wei89ddc322015-03-22 16:29:04 -050046 }
47
48 /**
49 * Constructs the ID corresponding to a given long value.
50 *
51 * @param value the underlying value of this ID
52 */
53 TunnelId(long value) {
Jian Lib6d998e2016-02-29 11:41:18 -080054 super(value);
wei wei89ddc322015-03-22 16:29:04 -050055 }
56
57 @Override
58 public String toString() {
Jian Lib6d998e2016-02-29 11:41:18 -080059 return "0x" + Long.toHexString(identifier);
wei wei89ddc322015-03-22 16:29:04 -050060 }
wei wei89ddc322015-03-22 16:29:04 -050061}