blob: 5ee273d04c336bc191b38958192e7a2aab31b929 [file] [log] [blame]
Yuta HIGUCHIa8a53eb2014-09-25 17:47:55 -07001package org.onlab.onos.store.serializers;
2
3import org.onlab.onos.net.ConnectPoint;
4import org.onlab.onos.net.DefaultLink;
5import org.onlab.onos.net.Link.Type;
6import org.onlab.onos.net.provider.ProviderId;
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 DefaultLink}.
15 */
16public class DefaultLinkSerializer extends Serializer<DefaultLink> {
17
18 /**
19 * Default constructor.
20 */
21 public DefaultLinkSerializer() {
22 // non-null, immutable
23 super(false, true);
24 }
25
26 @Override
27 public void write(Kryo kryo, Output output, DefaultLink object) {
28 kryo.writeClassAndObject(output, object.providerId());
29 kryo.writeClassAndObject(output, object.src());
30 kryo.writeClassAndObject(output, object.dst());
31 kryo.writeClassAndObject(output, object.type());
32 }
33
34 @Override
35 public DefaultLink read(Kryo kryo, Input input, Class<DefaultLink> type) {
36 ProviderId providerId = (ProviderId) kryo.readClassAndObject(input);
37 ConnectPoint src = (ConnectPoint) kryo.readClassAndObject(input);
38 ConnectPoint dst = (ConnectPoint) kryo.readClassAndObject(input);
39 Type linkType = (Type) kryo.readClassAndObject(input);
40 return new DefaultLink(providerId, src, dst, linkType);
41 }
42}