blob: fa12055c425f6d1ff7b72671e903502fa54f0a7c [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.util;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08002
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 {
Ray Milkey269ffb92014-04-03 14:43:30 -07009 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)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080011
12 /**
13 * Default constructor.
14 */
15 public FlowEntryErrorState() {
Ray Milkey269ffb92014-04-03 14:43:30 -070016 this.type = 0;
17 this.code = 0;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080018 }
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) {
Ray Milkey269ffb92014-04-03 14:43:30 -070027 this.type = type;
28 this.code = code;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080029 }
30
31 /**
32 * Get the error type.
33 *
34 * @return the error type.
35 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080036 @JsonProperty("type")
Ray Milkey269ffb92014-04-03 14:43:30 -070037 public short type() {
38 return type;
39 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080040
41 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080042 * Set the error type.
43 *
44 * @param type the error type to use.
45 */
46 @JsonProperty("type")
47 public void setType(short type) {
Ray Milkey269ffb92014-04-03 14:43:30 -070048 this.type = type;
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080049 }
50
51 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080052 * Get the error code.
53 *
54 * @return the error code.
55 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080056 @JsonProperty("code")
Ray Milkey269ffb92014-04-03 14:43:30 -070057 public short code() {
58 return code;
59 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080060
61 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080062 * Set the error code.
63 *
64 * @param code the error code to use.
65 */
66 @JsonProperty("code")
67 public void setCode(short code) {
Ray Milkey269ffb92014-04-03 14:43:30 -070068 this.code = code;
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080069 }
70
71 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080072 * Set the values of the error type and code.
73 *
74 * @param type the error type to use.
75 * @param code the error code to use.
76 */
77 public void setValue(short type, short code) {
Ray Milkey269ffb92014-04-03 14:43:30 -070078 this.type = type;
79 this.code = code;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080080 }
81
82 /**
83 * Convert the error type and code to a string.
Ray Milkey269ffb92014-04-03 14:43:30 -070084 * <p/>
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080085 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080086 * [type=1 code=2]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080087 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080088 * @return the error type and code as a string.
89 */
90 @Override
91 public String toString() {
Ray Milkey269ffb92014-04-03 14:43:30 -070092 String ret = "[type=" + this.type + " code=" + code + "]";
93 return ret;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080094 }
95}