jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [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 | */ |
| 16 | package org.onosproject.vtnrsc; |
| 17 | |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 18 | import org.onlab.util.Identifier; |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 19 | |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 20 | import java.util.UUID; |
| 21 | |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 24 | /** |
| 25 | * Immutable representation of a floating IP identifier. |
| 26 | */ |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 27 | public final class FloatingIpId extends Identifier<UUID> { |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 28 | // Public construction is prohibited |
| 29 | private FloatingIpId(UUID floatingIpId) { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 30 | super(checkNotNull(floatingIpId, "floatingIpId cannot be null")); |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Creates a floating IP identifier. |
| 35 | * |
| 36 | * @param floatingIpId the UUID id of floating IP identifier |
| 37 | * @return object of floating IP identifier |
| 38 | */ |
| 39 | public static FloatingIpId of(UUID floatingIpId) { |
| 40 | return new FloatingIpId(floatingIpId); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Creates a floating IP identifier. |
| 45 | * |
| 46 | * @param floatingIpId the floating IP identifier in string |
| 47 | * @return object of floating IP identifier |
| 48 | */ |
| 49 | public static FloatingIpId of(String floatingIpId) { |
| 50 | return new FloatingIpId(UUID.fromString(floatingIpId)); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns the floating IP identifier. |
| 55 | * |
| 56 | * @return the floating IP identifier |
| 57 | */ |
| 58 | public UUID floatingIpId() { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 59 | return identifier; |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 60 | } |
| 61 | } |