Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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.incubator.net.virtual; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 19 | import org.onlab.util.Identifier; |
Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Representation of network identity. |
| 23 | */ |
| 24 | @Beta |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 25 | public final class NetworkId extends Identifier<Long> { |
Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Represents no network, or an unspecified network. |
| 29 | */ |
| 30 | public static final NetworkId NONE = networkId(-1L); |
| 31 | |
| 32 | /** |
| 33 | * Represents the underlying physical network. |
| 34 | */ |
| 35 | public static final NetworkId PHYSICAL = networkId(0L); |
| 36 | |
Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 37 | // Public construction is prohibited |
| 38 | private NetworkId(long id) { |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 39 | super(id); |
Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | |
| 43 | // Default constructor for serialization |
| 44 | protected NetworkId() { |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 45 | super(-1L); |
Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Creates a network id using the supplied backing id. |
| 50 | * |
| 51 | * @param id network id |
| 52 | * @return network identifier |
| 53 | */ |
| 54 | public static NetworkId networkId(long id) { |
| 55 | return new NetworkId(id); |
| 56 | } |
Thomas Vachuska | 7b438af | 2015-07-07 09:52:07 -0700 | [diff] [blame] | 57 | } |