blob: 4ea5df864585810cd2225c518c1e574ec240da93 [file] [log] [blame]
Aaron Kruglikovb4916d02015-09-08 16:22:25 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-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
Jian Lib6d998e2016-02-29 11:41:18 -080019import org.onlab.util.Identifier;
20
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070021/**
22 * A wrapper class for a long used to identify domain level tunnels.
23 */
Jian Lib6d998e2016-02-29 11:41:18 -080024public final class DomainTunnelId extends Identifier<Long> {
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070025
26 /**
27 * Creates a tunnel identifier from the specified tunnel.
28 *
29 * @param value long value
30 * @return domain tunnel identifier
31 */
32 public static DomainTunnelId valueOf(long value) {
33 return new DomainTunnelId(value);
34 }
35
36 /**
37 * Creates a tunnel identifier from the specified tunnel.
38 *
39 * @param value long value as a string
40 * @return domain tunnel identifier
41 */
42 public static DomainTunnelId valueOf(String value) {
43 return new DomainTunnelId(Long.parseLong(value));
44 }
45
46 /**
47 * Constructor for serializer.
48 */
49 protected DomainTunnelId() {
Jian Lib6d998e2016-02-29 11:41:18 -080050 super(0L);
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070051 }
52
53 /**
54 * Constructs the Domain ID corresponding to a given long value.
55 *
56 * @param value the underlying value of this domain ID
57 */
58 public DomainTunnelId(long value) {
Jian Lib6d998e2016-02-29 11:41:18 -080059 super(value);
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070060 }
61
62 @Override
63 public String toString() {
Jian Lib6d998e2016-02-29 11:41:18 -080064 return "0x" + Long.toHexString(identifier);
Aaron Kruglikovb4916d02015-09-08 16:22:25 -070065 }
66}