blob: 9d2db47531a14231e54240a1a124881766add938 [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;
Yuta HIGUCHIeecee552014-10-16 14:09:01 -07006import org.onlab.onos.store.impl.Timestamped;
Madan Jampanifef9b3a2014-10-07 18:38:17 -07007
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);
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070038 @SuppressWarnings("unchecked")
Madan Jampanifef9b3a2014-10-07 18:38:17 -070039 Timestamped<PortDescription> portDescription = (Timestamped<PortDescription>) kryo.readClassAndObject(input);
40
41 return new InternalPortStatusEvent(providerId, deviceId, portDescription);
42 }
43}