blob: 52500f59c71ec6f292432c0e189d87e29c5342e2 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
Ayaka Koshibe414196d2014-09-17 13:46:43 -070017
alshabiba7f7ca82014-09-22 11:41:23 -070018import com.google.common.base.Objects;
19
Ayaka Koshibe414196d2014-09-17 13:46:43 -070020/**
21 * Representation of a Flow ID.
22 */
23public final class FlowId {
24
alshabiba7f7ca82014-09-22 11:41:23 -070025 private final long flowid;
Ayaka Koshibe414196d2014-09-17 13:46:43 -070026
alshabiba7f7ca82014-09-22 11:41:23 -070027 private FlowId(long id) {
Ayaka Koshibe414196d2014-09-17 13:46:43 -070028 this.flowid = id;
29 }
30
alshabib9290eea2014-09-22 11:58:17 -070031 public static FlowId valueOf(long id) {
Ayaka Koshibe414196d2014-09-17 13:46:43 -070032 return new FlowId(id);
33 }
34
alshabiba7f7ca82014-09-22 11:41:23 -070035 public long value() {
Ayaka Koshibe414196d2014-09-17 13:46:43 -070036 return flowid;
37 }
alshabiba7f7ca82014-09-22 11:41:23 -070038
39 @Override
40 public boolean equals(Object obj) {
41 if (this == obj) {
42 return true;
43 }
Yuta HIGUCHIadcafb62014-10-04 22:35:15 -070044 if (obj == null) {
45 return false;
46 }
alshabiba7f7ca82014-09-22 11:41:23 -070047 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 Koshibe414196d2014-09-17 13:46:43 -070058}