Use ByteBuf.readRetainedSlice()
[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 static java.util.Objects.requireNonNull;
11
12 import java.util.Objects;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
14 import org.opendaylight.yangtools.yang.common.Uint8;
15
16 /**
17  * Serializer key for a Nicira action.
18  *
19  * @author msunal
20  */
21 public class NiciraActionSerializerKey {
22
23     private final Uint8 version;
24     private final Class<? extends ActionChoice> subtype;
25
26     /**
27      * Contructor.
28      *
29      * @param version protocol wire version
30      * @param subtype nx_action_subtype
31      */
32     public NiciraActionSerializerKey(final Uint8 version, final Class<? extends ActionChoice> subtype) {
33         this.version = requireNonNull(version);
34         this.subtype = subtype;
35     }
36
37     public Uint8 getVersion() {
38         return version;
39     }
40
41     public Class<? extends ActionChoice> getSubtype() {
42         return subtype;
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = 1;
49         result = prime * result + Objects.hashCode(subtype);
50         result = prime * result + version.hashCode();
51         return result;
52     }
53
54     @Override
55     public boolean equals(final Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         NiciraActionSerializerKey other = (NiciraActionSerializerKey) obj;
66         return Objects.equals(subtype, other.subtype) && version.equals(other.version);
67     }
68
69     @Override
70     public String toString() {
71         return "NiciraActionSerializerKey [version=" + version + ", subtype=" + subtype + "]";
72     }
73
74 }