blob: 6ec41221f86f744d103a04df67b9f1c5910834d5 [file] [log] [blame]
Madan Jampanifef9b3a2014-10-07 18:38:17 -07001package org.onlab.onos.store.device.impl;
2
3import org.onlab.onos.net.DeviceId;
4import org.onlab.onos.net.device.PortDescription;
5import org.onlab.onos.net.provider.ProviderId;
6import org.onlab.onos.store.common.impl.Timestamped;
7
8import com.esotericsoftware.kryo.Kryo;
9import com.esotericsoftware.kryo.Serializer;
10import com.esotericsoftware.kryo.io.Input;
11import com.esotericsoftware.kryo.io.Output;
12
13/**
14 * Kryo Serializer for {@link InternalPortStatusEvent}.
15 */
16public class InternalPortStatusEventSerializer extends Serializer<InternalPortStatusEvent> {
17
18 /**
19 * Creates a serializer for {@link InternalPortStatusEvent}.
20 */
21 public InternalPortStatusEventSerializer() {
22 // does not accept null
23 super(false);
24 }
25
26 @Override
27 public void write(Kryo kryo, Output output, InternalPortStatusEvent event) {
28 kryo.writeClassAndObject(output, event.providerId());
29 kryo.writeClassAndObject(output, event.deviceId());
30 kryo.writeClassAndObject(output, event.portDescription());
31 }
32
33 @Override
34 public InternalPortStatusEvent read(Kryo kryo, Input input,
35 Class<InternalPortStatusEvent> type) {
36 ProviderId providerId = (ProviderId) kryo.readClassAndObject(input);
37 DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
38 Timestamped<PortDescription> portDescription = (Timestamped<PortDescription>) kryo.readClassAndObject(input);
39
40 return new InternalPortStatusEvent(providerId, deviceId, portDescription);
41 }
42}