blob: f9ca8baa817553f4ef35414452200d2ce5a0969c [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003import net.floodlightcontroller.util.serializers.FlowEntryErrorStateSerializer;
4
5import org.codehaus.jackson.annotate.JsonProperty;
6import org.codehaus.jackson.map.annotate.JsonSerialize;
7
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08008/**
9 * The class representing the Flow Entry error state.
10 */
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080011@JsonSerialize(using=FlowEntryErrorStateSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080012public class FlowEntryErrorState {
13 private short type; // The error type (e.g., see OF-1.3.1 spec, pp. 95)
14 private short code; // The error code (e.g., see OF-1.3.1 spec, pp. 95)
15
16 /**
17 * Default constructor.
18 */
19 public FlowEntryErrorState() {
20 this.type = 0;
21 this.code = 0;
22 }
23
24 /**
25 * Constructor for a given error type and code.
26 *
27 * @param type the error type to use.
28 * @param code the error code to use.
29 */
30 public FlowEntryErrorState(short type, short code) {
31 this.type = type;
32 this.code = code;
33 }
34
35 /**
36 * Get the error type.
37 *
38 * @return the error type.
39 */
40 public short type() { return type; }
41
42 /**
43 * Get the error code.
44 *
45 * @return the error code.
46 */
47 public short code() { return code; }
48
49 /**
50 * Set the values of the error type and code.
51 *
52 * @param type the error type to use.
53 * @param code the error code to use.
54 */
55 public void setValue(short type, short code) {
56 this.type = type;
57 this.code = code;
58 }
59
60 /**
61 * Convert the error type and code to a string.
62 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080063 * The string has the following form:
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080064 * [type=1 code=2]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080065 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080066 * @return the error type and code as a string.
67 */
68 @Override
69 public String toString() {
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080070 String ret = "[type=" + this.type + " code=" + code + "]";
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080071 return ret;
72 }
73}