Add methods for experimenter (de)serializer registration
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ExperimenterIdTypeDeserializerKey.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.yangtools.yang.binding.DataContainer;
12
13 /**
14  * @author michal.polkorab
15  */
16 public class ExperimenterIdTypeDeserializerKey extends ExperimenterIdDeserializerKey {
17
18     private long type;
19
20     /**
21      * @param <T>            type of target experimenter object
22      * @param version        protocol wire version
23      * @param experimenterId experimenter / vendor ID
24      * @param type           data type according to vendor implementation
25      * @param objectClass    class of object to be serialized
26      */
27     public <T extends DataContainer> ExperimenterIdTypeDeserializerKey(final short version, final long experimenterId,
28                                                                        final long type, Class<T> objectClass) {
29         super(version, experimenterId, objectClass);
30         this.type = type;
31     }
32
33     @Override
34     public int hashCode() {
35         final int prime = 31;
36         int result = super.hashCode();
37         result = prime * result + hashCodeOfLong(type);
38         return result;
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (!super.equals(obj)) {
44             return false;
45         }
46         if (!(obj instanceof ExperimenterIdTypeDeserializerKey)) {
47             return false;
48         }
49         ExperimenterIdTypeDeserializerKey other = (ExperimenterIdTypeDeserializerKey) obj;
50         if (type != other.type) {
51             return false;
52         }
53         return true;
54     }
55
56     @Override
57     public String toString() {
58         return super.toString() + "; type: " + type;
59     }
60 }