Add match support for nsh_flags and nsh_ttl
[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.action.grouping.ActionChoice;
11
12 /**
13  * Serializer key for a Nicira action.
14  *
15  * @author msunal
16  */
17 public class NiciraActionSerializerKey {
18
19     private final short version;
20     private final Class<? extends ActionChoice> subtype;
21
22     /**
23      * Contructor.
24      *
25      * @param version protocol wire version
26      * @param subtype nx_action_subtype
27      */
28     public NiciraActionSerializerKey(final short version, final Class<? extends ActionChoice> subtype) {
29         this.version = version;
30         this.subtype = subtype;
31     }
32
33     public short getVersion() {
34         return version;
35     }
36
37     public Class<? extends ActionChoice> getSubtype() {
38         return subtype;
39     }
40
41     @Override
42     public int hashCode() {
43         final int prime = 31;
44         int result = 1;
45         result = prime * result + (subtype == null ? 0 : subtype.hashCode());
46         result = prime * result + version;
47         return result;
48     }
49
50     @Override
51     public boolean equals(final Object obj) {
52         if (this == obj) {
53             return true;
54         }
55         if (obj == null) {
56             return false;
57         }
58         if (getClass() != obj.getClass()) {
59             return false;
60         }
61         NiciraActionSerializerKey other = (NiciraActionSerializerKey) obj;
62         if (subtype == null) {
63             if (other.subtype != null) {
64                 return false;
65             }
66         } else if (!subtype.equals(other.subtype)) {
67             return false;
68         }
69         if (version != other.version) {
70             return false;
71         }
72         return true;
73     }
74
75     @Override
76     public String toString() {
77         return "NiciraActionSerializerKey [version=" + version + ", subtype=" + subtype + "]";
78     }
79
80 }