Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
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 | */ |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.flow; |
| 17 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 18 | import com.google.common.base.Objects; |
| 19 | |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Representation of a Flow ID. |
| 22 | */ |
| 23 | public final class FlowId { |
| 24 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 25 | private final long flowid; |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 26 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 27 | private FlowId(long id) { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 28 | this.flowid = id; |
| 29 | } |
| 30 | |
alshabib | 9290eea | 2014-09-22 11:58:17 -0700 | [diff] [blame] | 31 | public static FlowId valueOf(long id) { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 32 | return new FlowId(id); |
| 33 | } |
| 34 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 35 | public long value() { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 36 | return flowid; |
| 37 | } |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 38 | |
| 39 | @Override |
| 40 | public boolean equals(Object obj) { |
| 41 | if (this == obj) { |
| 42 | return true; |
| 43 | } |
Yuta HIGUCHI | adcafb6 | 2014-10-04 22:35:15 -0700 | [diff] [blame] | 44 | if (obj == null) { |
| 45 | return false; |
| 46 | } |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 47 | if (obj.getClass() == this.getClass()) { |
| 48 | FlowId that = (FlowId) obj; |
| 49 | return Objects.equal(this.flowid, that.flowid); |
| 50 | } |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public int hashCode() { |
| 56 | return Objects.hashCode(this.flowid); |
| 57 | } |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 58 | } |