2015-07-02 12:12:34 +02:00
|
|
|
/**
|
2017-01-04 17:37:10 +01:00
|
|
|
* Copyright (C) 2015-2017 Lightbend Inc. <http://www.lightbend.com>
|
2015-07-02 12:12:34 +02:00
|
|
|
*/
|
2017-03-16 09:30:00 +01:00
|
|
|
package jdocs.ddata.protobuf;
|
2015-07-02 12:12:34 +02:00
|
|
|
|
2017-03-16 09:30:00 +01:00
|
|
|
import jdocs.ddata.TwoPhaseSet;
|
2015-07-02 12:12:34 +02:00
|
|
|
|
|
|
|
|
import akka.actor.ExtendedActorSystem;
|
|
|
|
|
|
|
|
|
|
public class TwoPhaseSetSerializerWithCompression extends TwoPhaseSetSerializer {
|
|
|
|
|
public TwoPhaseSetSerializerWithCompression(ExtendedActorSystem system) {
|
|
|
|
|
super(system);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#compression
|
|
|
|
|
@Override
|
|
|
|
|
public byte[] toBinary(Object obj) {
|
|
|
|
|
if (obj instanceof TwoPhaseSet) {
|
|
|
|
|
return compress(twoPhaseSetToProto((TwoPhaseSet) obj));
|
|
|
|
|
} else {
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"Can't serialize object of type " + obj.getClass());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object fromBinaryJava(byte[] bytes, Class<?> manifest) {
|
|
|
|
|
return twoPhaseSetFromBinary(decompress(bytes));
|
|
|
|
|
}
|
|
|
|
|
//#compression
|
|
|
|
|
}
|
|
|
|
|
|