blob: 142e352dcf67b051d0beacdb5b0df3b153997a56 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
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 Koshibe414196d2014-09-17 13:46:43 -070019package org.onlab.onos.net.flow;
20
alshabiba7f7ca82014-09-22 11:41:23 -070021import com.google.common.base.Objects;
22
Ayaka Koshibe414196d2014-09-17 13:46:43 -070023/**
24 * Representation of a Flow ID.
25 */
26public final class FlowId {
27
alshabiba7f7ca82014-09-22 11:41:23 -070028 private final long flowid;
Ayaka Koshibe414196d2014-09-17 13:46:43 -070029
alshabiba7f7ca82014-09-22 11:41:23 -070030 private FlowId(long id) {
Ayaka Koshibe414196d2014-09-17 13:46:43 -070031 this.flowid = id;
32 }
33
alshabib9290eea2014-09-22 11:58:17 -070034 public static FlowId valueOf(long id) {
Ayaka Koshibe414196d2014-09-17 13:46:43 -070035 return new FlowId(id);
36 }
37
alshabiba7f7ca82014-09-22 11:41:23 -070038 public long value() {
Ayaka Koshibe414196d2014-09-17 13:46:43 -070039 return flowid;
40 }
alshabiba7f7ca82014-09-22 11:41:23 -070041
42 @Override
43 public boolean equals(Object obj) {
44 if (this == obj) {
45 return true;
46 }
Yuta HIGUCHIadcafb62014-10-04 22:35:15 -070047 if (obj == null) {
48 return false;
49 }
alshabiba7f7ca82014-09-22 11:41:23 -070050 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 Koshibe414196d2014-09-17 13:46:43 -070061}