wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 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 | */ |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 16 | |
| 17 | package org.onosproject.incubator.net.tunnel; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 18 | |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 20 | import org.onlab.util.Identifier; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Representation of a Tunnel Id. |
| 24 | */ |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 25 | @Beta |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 26 | public final class TunnelId extends Identifier<String> { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 27 | /** |
| 28 | * Creates an tunnel identifier from the specified tunnel. |
| 29 | * |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 30 | * @param value string value |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 31 | * @return tunnel identifier |
| 32 | */ |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 33 | public static TunnelId valueOf(String value) { |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 34 | return new TunnelId(value); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Constructor for serializer. |
| 39 | */ |
| 40 | TunnelId() { |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 41 | super("0"); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /** |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 45 | * Constructs the ID corresponding to a given string value. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 46 | * |
| 47 | * @param value the underlying value of this ID |
| 48 | */ |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 49 | TunnelId(String value) { |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 50 | super(value); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public String toString() { |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 55 | return id(); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 56 | } |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 57 | } |