Bug 2756 - Action model update
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ExperimenterActionSerializerKey.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.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
13
14 /**
15  * @author michal.polkorab
16  */
17 public final class ExperimenterActionSerializerKey extends ActionSerializerKey<ExperimenterIdCase>
18         implements ExperimenterSerializerKey {
19
20     private Class<? extends ExperimenterActionSubType> actionSubType;
21
22     /**
23      * @param msgVersion protocol wire version
24      * @param experimenterId experimenter / vendor ID
25      * @param actionSubType vendor defined subtype
26      */
27     public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class<? extends ExperimenterActionSubType> actionSubType) {
28         super(msgVersion, ExperimenterIdCase.class, experimenterId);
29         this.actionSubType = actionSubType;
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = super.hashCode();
36         result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode());
37         return result;
38     }
39
40     @Override
41     public boolean equals(Object obj) {
42         if (this == obj) {
43             return true;
44         }
45         if (!super.equals(obj)) {
46             return false;
47         }
48         if (getClass() != obj.getClass()) {
49             return false;
50         }
51         ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj;
52         if (actionSubType == null) {
53             if (other.actionSubType != null) {
54                 return false;
55             }
56         } else if (!actionSubType.equals(other.actionSubType)) {
57             return false;
58         }
59         return true;
60     }
61 }