blob: 11731652ee2ed17c7aff0a384639731acdcebbb2 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Yuta HIGUCHI60a190b2014-11-07 16:24:47 -080016package org.onlab.onos.store.serializers.impl;
Yuta HIGUCHI3e0b6512014-10-07 17:43:56 -070017
18import org.onlab.onos.store.cluster.messaging.MessageSubject;
19
20import com.esotericsoftware.kryo.Kryo;
21import com.esotericsoftware.kryo.Serializer;
22import com.esotericsoftware.kryo.io.Input;
23import com.esotericsoftware.kryo.io.Output;
24
25public final class MessageSubjectSerializer extends Serializer<MessageSubject> {
26
27 /**
28 * Creates a serializer for {@link MessageSubject}.
29 */
30 public MessageSubjectSerializer() {
31 // non-null, immutable
32 super(false, true);
33 }
34
35
36 @Override
37 public void write(Kryo kryo, Output output, MessageSubject object) {
38 output.writeString(object.value());
39 }
40
41 @Override
42 public MessageSubject read(Kryo kryo, Input input,
43 Class<MessageSubject> type) {
44 return new MessageSubject(input.readString());
45 }
46}