Yuta HIGUCHI

use encode/decode instead of serialize/deserialize

Change-Id: I273bb86d32cb763e1eb8bbbe4efa7a8dab541c51
package org.onlab.onos.store.cluster.messaging;
/**
* Service for encoding & decoding intra-cluster messages.
* Service for encoding & decoding intra-cluster message payload.
*/
public interface SerializationService {
......@@ -11,7 +11,7 @@ public interface SerializationService {
* @param buffer byte buffer with message(s)
* @return parsed message
*/
Object decode(byte[] data);
<T> T decode(byte[] data);
/**
* Encodes the specified message into the given byte buffer.
......
......@@ -52,7 +52,7 @@ public class MessageSerializer implements SerializationService {
@Override
public Object decode(byte[] data) {
public <T> T decode(byte[] data) {
return serializerPool.deserialize(data);
}
......
......@@ -50,7 +50,7 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel
* @return serialized object
*/
protected byte[] serialize(Object obj) {
return kryoSerializationService.serialize(obj);
return kryoSerializationService.encode(obj);
}
/**
......@@ -61,7 +61,7 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel
* @return deserialized object
*/
protected <T> T deserialize(byte[] bytes) {
return kryoSerializationService.deserialize(bytes);
return kryoSerializationService.decode(bytes);
}
......
......@@ -34,12 +34,12 @@ public final class OptionalCacheLoader<K, V> extends
@Override
public Optional<V> load(K key) throws Exception {
byte[] keyBytes = kryoSerializationService.serialize(key);
byte[] keyBytes = kryoSerializationService.encode(key);
byte[] valBytes = rawMap.get(keyBytes);
if (valBytes == null) {
return Optional.absent();
}
V dev = kryoSerializationService.deserialize(valBytes);
V dev = kryoSerializationService.decode(valBytes);
return Optional.of(dev);
}
}
......
......@@ -43,12 +43,12 @@ public class KryoSerializationManager implements KryoSerializationService {
}
@Override
public byte[] serialize(final Object obj) {
public byte[] encode(final Object obj) {
return serializerPool.serialize(obj);
}
@Override
public <T> T deserialize(final byte[] bytes) {
public <T> T decode(final byte[] bytes) {
if (bytes == null) {
return null;
}
......@@ -56,12 +56,12 @@ public class KryoSerializationManager implements KryoSerializationService {
}
@Override
public void serialize(Object obj, ByteBuffer buffer) {
public void encode(Object obj, ByteBuffer buffer) {
serializerPool.serialize(obj, buffer);
}
@Override
public <T> T deserialize(ByteBuffer buffer) {
public <T> T decode(ByteBuffer buffer) {
return serializerPool.deserialize(buffer);
}
......
......@@ -15,7 +15,7 @@ public interface KryoSerializationService {
* @param obj object to be serialized
* @return serialized bytes
*/
public byte[] serialize(final Object obj);
public byte[] encode(final Object obj);
/**
* Serializes the specified object into bytes using one of the
......@@ -24,7 +24,7 @@ public interface KryoSerializationService {
* @param obj object to be serialized
* @param buffer to write serialized bytes
*/
public void serialize(final Object obj, ByteBuffer buffer);
public void encode(final Object obj, ByteBuffer buffer);
/**
* Deserializes the specified bytes into an object using one of the
......@@ -33,7 +33,7 @@ public interface KryoSerializationService {
* @param bytes bytes to be deserialized
* @return deserialized object
*/
public <T> T deserialize(final byte[] bytes);
public <T> T decode(final byte[] bytes);
/**
* Deserializes the specified bytes into an object using one of the
......@@ -42,5 +42,5 @@ public interface KryoSerializationService {
* @param buffer bytes to be deserialized
* @return deserialized object
*/
public <T> T deserialize(final ByteBuffer buffer);
public <T> T decode(final ByteBuffer buffer);
}
......