Bump mdsal to 5.0.2
[openflowplugin.git] / openflowjava / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ActionSerializerKey.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 package org.opendaylight.openflowjava.protocol.api.keys;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
12 import org.opendaylight.yangtools.yang.common.Uint32;
13
14 /**
15  * Key for an action serializer.
16  *
17  * @author michal.polkorab
18  * @param <T> action type
19  */
20 public class ActionSerializerKey<T extends ActionChoice> extends MessageTypeKey<Action>
21         implements ExperimenterSerializerKey {
22
23     private final Class<T> actionType;
24     private final Uint32 experimenterId;
25
26     /**
27      * Constructor.
28      *
29      * @param msgVersion protocol wire version
30      * @param actionType type of action
31      * @param experimenterId experimenter / vendor ID
32      */
33     public ActionSerializerKey(final short msgVersion, final Class<T> actionType, final Uint32 experimenterId) {
34         super(msgVersion, Action.class);
35         this.actionType = actionType;
36         this.experimenterId = experimenterId;
37     }
38
39     /**
40      * Constructor.
41      *
42      * @param msgVersion protocol wire version
43      * @param actionType type of action
44      * @param experimenterId experimenter / vendor ID
45      */
46     @Deprecated(forRemoval = true)
47     public ActionSerializerKey(final short msgVersion, final Class<T> actionType, final Long experimenterId) {
48         this(msgVersion, actionType, experimenterId == null ? (Uint32) null : Uint32.valueOf(experimenterId));
49     }
50
51     @Override
52     public int hashCode() {
53         final int prime = 31;
54         int result = super.hashCode();
55         result = prime * result + (actionType == null ? 0 : actionType.hashCode());
56         result = prime * result + (experimenterId == null ? 0 : experimenterId.hashCode());
57         return result;
58     }
59
60     @Override
61     public boolean equals(final Object obj) {
62         if (this == obj) {
63             return true;
64         }
65         if (!super.equals(obj)) {
66             return false;
67         }
68         if (getClass() != obj.getClass()) {
69             return false;
70         }
71         ActionSerializerKey<?> other = (ActionSerializerKey<?>) obj;
72         if (actionType == null) {
73             if (other.actionType != null) {
74                 return false;
75             }
76         } else if (!actionType.equals(other.actionType)) {
77             return false;
78         }
79         if (experimenterId == null) {
80             if (other.experimenterId != null) {
81                 return false;
82             }
83         } else if (!experimenterId.equals(other.experimenterId)) {
84             return false;
85         }
86         return true;
87     }
88
89     @Override
90     public String toString() {
91         return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId;
92     }
93 }