Fix checkstyle warnings in netconf-cli
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / action / OFActionVendor.java
1 package org.openflow.protocol.action;
2
3 import java.nio.ByteBuffer;
4
5 /**
6  *
7  * @author David Erickson (daviderickson@cs.stanford.edu)
8  */
9 public class OFActionVendor extends OFAction {
10     public static int MINIMUM_LENGTH = 8;
11     
12     protected int vendor;
13
14         public enum ActionVendorID {
15                 AVI_CISCO(0xC);
16         private int value;
17         private ActionVendorID(int value) {
18                 this.value = value;
19         }
20         public int getValue() {
21                 return this.value;
22         }
23         }       
24
25     public OFActionVendor() {
26         super();
27         super.setType(OFActionType.VENDOR);
28         super.setLength((short) MINIMUM_LENGTH);
29     }
30
31     /**
32      * @return the vendor
33      */
34     public int getVendor() {
35         return vendor;
36     }
37
38     /**
39      * @param vendor the vendor to set
40      */
41     public void setVendor(int vendor) {
42         this.vendor = vendor;
43     }
44
45     @Override
46     public void readFrom(ByteBuffer data) {
47         super.readFrom(data);
48         this.vendor = data.getInt();
49         if (this.vendor == ActionVendorID.AVI_CISCO.getValue()) {
50                 ActionVendorOutputNextHop nh = new ActionVendorOutputNextHop();
51                 nh.readFrom(data);
52         }
53                 
54     }
55
56     @Override
57     public void writeTo(ByteBuffer data) {
58         super.writeTo(data);
59         data.putInt(this.vendor);
60     }
61
62     @Override
63     public int hashCode() {
64         final int prime = 379;
65         int result = super.hashCode();
66         result = prime * result + vendor;
67         return result;
68     }
69
70     @Override
71     public boolean equals(Object obj) {
72         if (this == obj) {
73             return true;
74         }
75         if (!super.equals(obj)) {
76             return false;
77         }
78         if (!(obj instanceof OFActionVendor)) {
79             return false;
80         }
81         OFActionVendor other = (OFActionVendor) obj;
82         if (vendor != other.vendor) {
83             return false;
84         }
85         return true;
86     }
87 }