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