Make sure RequestContext has a constant XID
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / device / Xid.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.api.openflow.device;
10
11 import com.google.common.base.Preconditions;
12
13 /**
14  * Created by Martin Bobak <mbobak@cisco.com> on 26.2.2015.
15  */
16 public final class Xid {
17     private final Long value;
18
19     public Xid(final Long value) {
20         this.value = Preconditions.checkNotNull(value);
21     }
22
23     public Long getValue() {
24         return value;
25     }
26
27     @Override
28     public int hashCode() {
29         final int prime = 31;
30         int result = 1;
31         result = prime * result + value.hashCode();
32         return result;
33     }
34
35     @Override
36     public boolean equals(final Object obj) {
37         if (this == obj) {
38             return true;
39         }
40         if (!(obj instanceof Xid)) {
41             return false;
42         }
43         return value.equals(((Xid) obj).value);
44     }
45
46     @Override
47     public String toString() {
48         return "Xid [value=" + value + "]";
49     }
50 }