Ayaka Koshibe | 8441136 | 2014-10-01 09:33:42 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.store.serializers; |
| 2 | |
| 3 | import org.onlab.onos.net.MastershipRole; |
| 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 | /** |
| 11 | * Kryo Serializer for {@link org.onlab.onos.net.MastershipRole}. |
| 12 | */ |
| 13 | public class MastershipRoleSerializer extends Serializer<MastershipRole> { |
| 14 | |
| 15 | @Override |
| 16 | public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) { |
| 17 | final String role = kryo.readObject(input, String.class); |
| 18 | return MastershipRole.valueOf(role); |
| 19 | } |
| 20 | |
| 21 | @Override |
| 22 | public void write(Kryo kryo, Output output, MastershipRole object) { |
| 23 | kryo.writeObject(output, object.toString()); |
| 24 | } |
| 25 | |
| 26 | } |