blob: 4f4a9e63775c59ce0ca1f559a63b8084fdedc1a8 [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;
Madan Jampanifef9b3a2014-10-07 18:38:17 -07006import org.onlab.onos.net.device.PortDescription;
7import org.onlab.onos.net.provider.ProviderId;
Yuta HIGUCHIeecee552014-10-16 14:09:01 -07008import org.onlab.onos.store.impl.Timestamped;
Madan Jampanifef9b3a2014-10-07 18:38:17 -07009
10import com.esotericsoftware.kryo.Kryo;
11import com.esotericsoftware.kryo.Serializer;
12import com.esotericsoftware.kryo.io.Input;
13import com.esotericsoftware.kryo.io.Output;
14
15/**
16 * Kryo Serializer for {@link InternalPortEvent}.
17 */
18public class InternalPortEventSerializer extends Serializer<InternalPortEvent> {
19
20 /**
21 * Creates a serializer for {@link InternalPortEvent}.
22 */
23 public InternalPortEventSerializer() {
24 // does not accept null
25 super(false);
26 }
27
28 @Override
29 public void write(Kryo kryo, Output output, InternalPortEvent event) {
30 kryo.writeClassAndObject(output, event.providerId());
31 kryo.writeClassAndObject(output, event.deviceId());
32 kryo.writeClassAndObject(output, event.portDescriptions());
33 }
34
35 @Override
36 public InternalPortEvent read(Kryo kryo, Input input,
37 Class<InternalPortEvent> type) {
38 ProviderId providerId = (ProviderId) kryo.readClassAndObject(input);
39 DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
Yuta HIGUCHI74ebeff12014-10-07 19:54:05 -070040 Timestamped<List<PortDescription>> portDescriptions
41 = (Timestamped<List<PortDescription>>) kryo.readClassAndObject(input);
Madan Jampanifef9b3a2014-10-07 18:38:17 -070042
43 return new InternalPortEvent(providerId, deviceId, portDescriptions);
44 }
45}