com.casper.sdk.jackson.deserializer.KeyDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of casper-java-sdk Show documentation
Show all versions of casper-java-sdk Show documentation
SDK to streamline the 3rd party Java client integration processes. Such 3rd parties include exchanges & app developers.
The newest version!
package com.casper.sdk.jackson.deserializer;
import com.casper.sdk.exception.NoSuchKeyTagException;
import com.casper.sdk.model.key.Key;
import com.casper.sdk.model.key.KeyTag;
import java.util.Arrays;
/**
* Customize the mapping of Casper's PublicKey
*
* @author Alexandre Carvalho
* @author Andre Bertolace
* @since 0.0.1
*/
public class KeyDeserializer extends AbstractSerializedKeyTaggedHexDeserializer {
@Override
protected Key getInstanceOf() {
return new Key();
}
@Override
protected void loadKey(Key key, byte[] bytes) throws NoSuchKeyTagException {
key.setTag(KeyTag.getByTag(bytes[0]));
key.setKey(Arrays.copyOfRange(bytes, 1, bytes.length));
}
}