Madan Jampani | fef9b3a | 2014-10-07 18:38:17 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.device.impl; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import org.onlab.onos.net.DeviceId; |
Madan Jampani | fef9b3a | 2014-10-07 18:38:17 -0700 | [diff] [blame] | 6 | import org.onlab.onos.net.device.PortDescription; |
| 7 | import org.onlab.onos.net.provider.ProviderId; |
Yuta HIGUCHI | eecee55 | 2014-10-16 14:09:01 -0700 | [diff] [blame] | 8 | import org.onlab.onos.store.impl.Timestamped; |
Madan Jampani | fef9b3a | 2014-10-07 18:38:17 -0700 | [diff] [blame] | 9 | |
| 10 | import com.esotericsoftware.kryo.Kryo; |
| 11 | import com.esotericsoftware.kryo.Serializer; |
| 12 | import com.esotericsoftware.kryo.io.Input; |
| 13 | import com.esotericsoftware.kryo.io.Output; |
| 14 | |
| 15 | /** |
| 16 | * Kryo Serializer for {@link InternalPortEvent}. |
| 17 | */ |
| 18 | public 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); |
Ray Milkey | 5154ec3 | 2014-10-22 10:51:18 -0700 | [diff] [blame] | 40 | |
| 41 | @SuppressWarnings("unchecked") |
Yuta HIGUCHI | 74ebeff1 | 2014-10-07 19:54:05 -0700 | [diff] [blame] | 42 | Timestamped<List<PortDescription>> portDescriptions |
| 43 | = (Timestamped<List<PortDescription>>) kryo.readClassAndObject(input); |
Madan Jampani | fef9b3a | 2014-10-07 18:38:17 -0700 | [diff] [blame] | 44 | |
| 45 | return new InternalPortEvent(providerId, deviceId, portDescriptions); |
| 46 | } |
| 47 | } |