Yuta HIGUCHI | 3e0b651 | 2014-10-07 17:43:56 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.serializers; |
| 2 | |
| 3 | import org.onlab.onos.store.cluster.messaging.MessageSubject; |
| 4 | |
| 5 | import com.esotericsoftware.kryo.Kryo; |
| 6 | import com.esotericsoftware.kryo.Serializer; |
| 7 | import com.esotericsoftware.kryo.io.Input; |
| 8 | import com.esotericsoftware.kryo.io.Output; |
| 9 | |
| 10 | public final class MessageSubjectSerializer extends Serializer<MessageSubject> { |
| 11 | |
| 12 | /** |
| 13 | * Creates a serializer for {@link MessageSubject}. |
| 14 | */ |
| 15 | public MessageSubjectSerializer() { |
| 16 | // non-null, immutable |
| 17 | super(false, true); |
| 18 | } |
| 19 | |
| 20 | |
| 21 | @Override |
| 22 | public void write(Kryo kryo, Output output, MessageSubject object) { |
| 23 | output.writeString(object.value()); |
| 24 | } |
| 25 | |
| 26 | @Override |
| 27 | public MessageSubject read(Kryo kryo, Input input, |
| 28 | Class<MessageSubject> type) { |
| 29 | return new MessageSubject(input.readString()); |
| 30 | } |
| 31 | } |