Timestamp, OnosTimestamp and it's serializer
Change-Id: I02e3563229ddae8fc4b705c708f4066d82e24cf4
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java b/core/store/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
new file mode 100644
index 0000000..812bc9d
--- /dev/null
+++ b/core/store/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
@@ -0,0 +1,37 @@
+package org.onlab.onos.store.serializers;
+
+import org.onlab.onos.net.ElementId;
+import org.onlab.onos.store.impl.OnosTimestamp;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+/**
+ * Kryo Serializer for {@link OnosTimestamp}.
+ */
+public class OnosTimestampSerializer extends Serializer<OnosTimestamp> {
+
+ /**
+ * Default constructor.
+ */
+ public OnosTimestampSerializer() {
+ // non-null, immutable
+ super(false, true);
+ }
+ @Override
+ public void write(Kryo kryo, Output output, OnosTimestamp object) {
+ kryo.writeClassAndObject(output, object.id());
+ output.writeInt(object.termNumber());
+ output.writeInt(object.sequenceNumber());
+ }
+
+ @Override
+ public OnosTimestamp read(Kryo kryo, Input input, Class<OnosTimestamp> type) {
+ ElementId id = (ElementId) kryo.readClassAndObject(input);
+ final int term = input.readInt();
+ final int sequence = input.readInt();
+ return new OnosTimestamp(id, term, sequence);
+ }
+}