BUG-2794: Incorporated model Action api changes in OFJava to openflowplugin
[openflowplugin.git] / extension / openflowjava-extension-nicira-api / src / main / java / org / opendaylight / openflowjava / nx / api / NiciraActionSerializerKey.java
1 /**
2  * Copyright (c) 2014 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 package org.opendaylight.openflowjava.nx.api;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
11
12 /**
13  * @author msunal
14  *
15  */
16 public class NiciraActionSerializerKey {
17     
18     private final short version;
19     private final Class<? extends ExperimenterActionSubType> subtype;
20
21     /**
22      * @param version protocol wire version
23      * @param subtype nx_action_subtype
24      */
25     public NiciraActionSerializerKey(short version, Class<? extends ExperimenterActionSubType> subtype) {
26         this.version = version;
27         this.subtype = subtype;
28     }
29
30     public short getVersion() {
31         return version;
32     }
33
34     public Class<? extends ExperimenterActionSubType> getSubtype() {
35         return subtype;
36     }
37
38     @Override
39     public int hashCode() {
40         final int prime = 31;
41         int result = 1;
42         result = prime * result + ((subtype == null) ? 0 : subtype.hashCode());
43         result = prime * result + version;
44         return result;
45     }
46
47     @Override
48     public boolean equals(Object obj) {
49         if (this == obj)
50             return true;
51         if (obj == null)
52             return false;
53         if (getClass() != obj.getClass())
54             return false;
55         NiciraActionSerializerKey other = (NiciraActionSerializerKey) obj;
56         if (subtype == null) {
57             if (other.subtype != null)
58                 return false;
59         } else if (!subtype.equals(other.subtype))
60             return false;
61         if (version != other.version)
62             return false;
63         return true;
64     }
65
66     @Override
67     public String toString() {
68         return "NiciraActionSerializerKey [version=" + version + ", subtype=" + subtype + "]";
69     }
70
71 }