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