Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 17 | |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 18 | import org.onlab.util.Identifier; |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 19 | |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Representation of a Flow ID. |
| 22 | */ |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 23 | public final class FlowId extends Identifier<Long> { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 24 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 25 | private FlowId(long id) { |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 26 | super(id); |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 27 | } |
| 28 | |
Jonathan Hart | 84f4f31 | 2016-03-03 08:17:11 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Creates a flow ID from a long value. |
| 31 | * |
| 32 | * @param id long value |
| 33 | * @return flow ID |
| 34 | */ |
alshabib | 9290eea | 2014-09-22 11:58:17 -0700 | [diff] [blame] | 35 | public static FlowId valueOf(long id) { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 36 | return new FlowId(id); |
| 37 | } |
| 38 | |
Jonathan Hart | 84f4f31 | 2016-03-03 08:17:11 -0800 | [diff] [blame] | 39 | /** |
| 40 | * Gets the flow ID value. |
| 41 | * |
| 42 | * @return flow ID value as long |
| 43 | */ |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 44 | public long value() { |
Jian Li | b6d998e | 2016-02-29 11:41:18 -0800 | [diff] [blame] | 45 | return this.identifier; |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 46 | } |
Jonathan Hart | 84f4f31 | 2016-03-03 08:17:11 -0800 | [diff] [blame] | 47 | |
| 48 | @Override |
| 49 | public String toString() { |
| 50 | return Long.toHexString(identifier); |
| 51 | } |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 52 | } |