Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util.serializers; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | |
| 5 | import org.codehaus.jackson.JsonGenerator; |
| 6 | import org.codehaus.jackson.JsonProcessingException; |
| 7 | import org.codehaus.jackson.map.JsonSerializer; |
| 8 | import org.codehaus.jackson.map.SerializerProvider; |
| 9 | |
| 10 | import net.floodlightcontroller.util.FlowEntryErrorState; |
| 11 | |
| 12 | /** |
| 13 | * Serialize a Flow Entry Error State as a string. |
| 14 | */ |
| 15 | public class FlowEntryErrorStateSerializer extends JsonSerializer<FlowEntryErrorState> { |
| 16 | |
| 17 | @Override |
| 18 | public void serialize(FlowEntryErrorState flowEntryErrorState, |
| 19 | JsonGenerator jGen, SerializerProvider serializer) |
| 20 | throws IOException, JsonProcessingException { |
| 21 | jGen.writeStartObject(); |
| 22 | jGen.writeNumberField("type", flowEntryErrorState.type()); |
| 23 | jGen.writeNumberField("code", flowEntryErrorState.code()); |
| 24 | jGen.writeEndObject(); |
| 25 | } |
| 26 | } |