4e33c56ca293055ca8e8f82d0512944362cc9503
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ActionSerializerKey.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.api.keys;\r
10 \r
11 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
14 \r
15 /**\r
16  * @author michal.polkorab\r
17  * @param <TYPE> action type\r
18  */\r
19 public class ActionSerializerKey<TYPE extends ActionBase> extends MessageTypeKey<Action> {\r
20 \r
21     private Class<TYPE> actionType;\r
22     private Long experimenterId;\r
23 \r
24     /**\r
25      * @param msgVersion protocol wire version\r
26      * @param actionType type of action\r
27      * @param experimenterId experimenter / vendor ID\r
28      */\r
29     public ActionSerializerKey(short msgVersion, Class<TYPE> actionType,\r
30             Long experimenterId) {\r
31         super(msgVersion, Action.class);\r
32         this.actionType = actionType;\r
33         this.experimenterId = experimenterId;\r
34     }\r
35 \r
36     @Override\r
37     public int hashCode() {\r
38         final int prime = 31;\r
39         int result = super.hashCode();\r
40         result = prime * result + ((actionType == null) ? 0 : actionType.hashCode());\r
41         result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());\r
42         return result;\r
43     }\r
44 \r
45     @Override\r
46     public boolean equals(Object obj) {\r
47         if (this == obj) {\r
48             return true;\r
49         }\r
50         if (!super.equals(obj)) {\r
51             return false;\r
52         }\r
53         if (getClass() != obj.getClass()) {\r
54             return false;\r
55         }\r
56         ActionSerializerKey<?> other = (ActionSerializerKey<?>) obj;\r
57         if (actionType == null) {\r
58             if (other.actionType != null) {\r
59                 return false;\r
60             }\r
61         } else if (!actionType.equals(other.actionType)) {\r
62             return false;\r
63         }\r
64         if (experimenterId == null) {\r
65             if (other.experimenterId != null) {\r
66                 return false;\r
67             }\r
68         } else if (!experimenterId.equals(other.experimenterId)) {\r
69             return false;\r
70         }\r
71         return true;\r
72     }\r
73 \r
74     @Override\r
75     public String toString() {\r
76         return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId;\r
77     }\r
78 }