blob: bf1708d749ff5d33f000f1ecac08bcf427368850 [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08005/**
6 * The class representing the Flow Entry error state.
7 */
8public class FlowEntryErrorState {
9 private short type; // The error type (e.g., see OF-1.3.1 spec, pp. 95)
10 private short code; // The error code (e.g., see OF-1.3.1 spec, pp. 95)
11
12 /**
13 * Default constructor.
14 */
15 public FlowEntryErrorState() {
16 this.type = 0;
17 this.code = 0;
18 }
19
20 /**
21 * Constructor for a given error type and code.
22 *
23 * @param type the error type to use.
24 * @param code the error code to use.
25 */
26 public FlowEntryErrorState(short type, short code) {
27 this.type = type;
28 this.code = code;
29 }
30
31 /**
32 * Get the error type.
33 *
34 * @return the error type.
35 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080036 @JsonProperty("type")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080037 public short type() { return type; }
38
39 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080040 * Set the error type.
41 *
42 * @param type the error type to use.
43 */
44 @JsonProperty("type")
45 public void setType(short type) {
46 this.type = type;
47 }
48
49 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080050 * Get the error code.
51 *
52 * @return the error code.
53 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080054 @JsonProperty("code")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080055 public short code() { return code; }
56
57 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080058 * Set the error code.
59 *
60 * @param code the error code to use.
61 */
62 @JsonProperty("code")
63 public void setCode(short code) {
64 this.code = code;
65 }
66
67 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080068 * Set the values of the error type and code.
69 *
70 * @param type the error type to use.
71 * @param code the error code to use.
72 */
73 public void setValue(short type, short code) {
74 this.type = type;
75 this.code = code;
76 }
77
78 /**
79 * Convert the error type and code to a string.
80 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080081 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080082 * [type=1 code=2]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080083 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080084 * @return the error type and code as a string.
85 */
86 @Override
87 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080088 String ret = "[type=" + this.type + " code=" + code + "]";
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080089 return ret;
90 }
91}