Bug 2245 Fixed Avoid cycle between java packages
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ExperimenterIdDeserializerKey.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. 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.openflowjava.protocol.api.keys;
10
11 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13
14 /**
15  * @author michal.polkorab
16  *
17  */
18 public final class ExperimenterIdDeserializerKey extends MessageCodeKey
19         implements ExperimenterDeserializerKey {
20
21     private Long experimenterId;
22
23     /**
24      * @param version protocol wire version
25      * @param experimenterId experimenter / vendor ID
26      * @param objectClass class of created object
27      */
28     public <E extends DataObject> ExperimenterIdDeserializerKey(short version,
29             Long experimenterId, Class<E> objectClass) {
30         super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass);
31         this.experimenterId = experimenterId;
32     }
33
34
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         int result = super.hashCode();
39         result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());
40         return result;
41     }
42
43     @Override
44     public boolean equals(Object obj) {
45         if (this == obj) {
46             return true;
47         }
48         if (!super.equals(obj)) {
49             return false;
50         }
51         if (!(obj instanceof ExperimenterIdDeserializerKey)) {
52             return false;
53         }
54         ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj;
55         if (experimenterId == null) {
56             if (other.experimenterId != null) {
57                 return false;
58             }
59         } else if (!experimenterId.equals(other.experimenterId)) {
60             return false;
61         }
62         return true;
63     }
64
65     @Override
66     public String toString() {
67         return super.toString() + " experimenterID: " + experimenterId;
68     }
69 }