Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.flow; |
| 20 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 21 | import com.google.common.base.Objects; |
| 22 | |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Representation of a Flow ID. |
| 25 | */ |
| 26 | public final class FlowId { |
| 27 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 28 | private final long flowid; |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 29 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 30 | private FlowId(long id) { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 31 | this.flowid = id; |
| 32 | } |
| 33 | |
alshabib | 9290eea | 2014-09-22 11:58:17 -0700 | [diff] [blame] | 34 | public static FlowId valueOf(long id) { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 35 | return new FlowId(id); |
| 36 | } |
| 37 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 38 | public long value() { |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 39 | return flowid; |
| 40 | } |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 41 | |
| 42 | @Override |
| 43 | public boolean equals(Object obj) { |
| 44 | if (this == obj) { |
| 45 | return true; |
| 46 | } |
Yuta HIGUCHI | adcafb6 | 2014-10-04 22:35:15 -0700 | [diff] [blame] | 47 | if (obj == null) { |
| 48 | return false; |
| 49 | } |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 50 | if (obj.getClass() == this.getClass()) { |
| 51 | FlowId that = (FlowId) obj; |
| 52 | return Objects.equal(this.flowid, that.flowid); |
| 53 | } |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public int hashCode() { |
| 59 | return Objects.hashCode(this.flowid); |
| 60 | } |
Ayaka Koshibe | 414196d | 2014-09-17 13:46:43 -0700 | [diff] [blame] | 61 | } |