Tsz-wo Sze created HDDS-14655:
---------------------------------
Summary: Add a generic type to ScmCodec
Key: HDDS-14655
URL: https://issues.apache.org/jira/browse/HDDS-14655
Project: Apache Ozone
Issue Type: Sub-task
Components: SCM HA
Reporter: Tsz-wo Sze
Add a generic type:
{code:java}
public interface ScmCodec<T> {
ByteString serialize(T object) throws InvalidProtocolBufferException;
T deserialize(Class<?> type, ByteString value) throws
InvalidProtocolBufferException;
}
{code}
Then, the subclass implementations does not have to cast the objects.
{code:java}
public class ScmBigIntegerCodec implements ScmCodec<BigInteger> {
@Override
public ByteString serialize(BigInteger object) {
// BigInteger returns a new byte[].
return UnsafeByteOperations.unsafeWrap(object.toByteArray());
}
@Override
public BigInteger deserialize(Class<?> type, ByteString value) {
return new BigInteger(value.toByteArray());
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]