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