blob: 26211674982e3a09368cb29c5cda8a6ee9c2d3f5 [file] [log] [blame]
Ray Milkey2fa6ca42014-06-13 15:38:20 -07001package net.onrc.onos.core.topology.web.serializers;
2
3import net.onrc.onos.core.topology.LinkEvent;
4import org.codehaus.jackson.JsonGenerator;
5import org.codehaus.jackson.map.SerializerProvider;
6import org.codehaus.jackson.map.ser.std.SerializerBase;
7
8import java.io.IOException;
9
10/**
11 * JSON serializer for LinkEvents.
12 */
13public class LinkEventSerializer extends SerializerBase<LinkEvent> {
14
15 /**
16 * Public constructor - just calls its super class constructor.
17 */
18 public LinkEventSerializer() {
19 super(LinkEvent.class);
20 }
21
22 /**
23 * Serializes a LinkEvent object.
24 *
25 * @param linkEvent LinkEvent to serialize
26 * @param jsonGenerator generator to add the serialized object to
27 * @param serializerProvider not used
28 * @throws IOException if the JSON serialization fails
29 */
30 @Override
31 public void serialize(final LinkEvent linkEvent,
32 final JsonGenerator jsonGenerator,
33 final SerializerProvider serializerProvider)
34 throws IOException {
35
36 jsonGenerator.writeStartObject();
37
38 jsonGenerator.writeObjectField("src", linkEvent.getSrc());
39 jsonGenerator.writeObjectField("dst", linkEvent.getDst());
40
41 jsonGenerator.writeEndObject();
42 }
43}