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