com.casper.sdk.model.clvalue.serde.CasperDeserializableObject 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.model.clvalue.serde;
import com.casper.sdk.exception.NoSuchTypeException;
import com.casper.sdk.model.clvalue.AbstractCLValue;
import dev.oak3.sbs4j.DeserializerBuffer;
import dev.oak3.sbs4j.exception.ValueDeserializationException;
import dev.oak3.sbs4j.interfaces.DeserializableObject;
/**
* Defines an object as being capable of encoding with {@link DeserializerBuffer}
*
* @author Alexandre Carvalho
* @author Andre Bertolace
* @since 0.2.2
*/
public interface CasperDeserializableObject extends DeserializableObject {
/**
* Called when the object's values must be deserialized
*
* @param deser the deserializer to be used
* @param target target deserialization standard
* @throws ValueDeserializationException exception holding information of failure to deserialize a value
*/
AbstractCLValue, ?> deserialize(DeserializerBuffer deser, Target target) throws ValueDeserializationException, NoSuchTypeException;
/**
* Called when the object's values must be deserialized
*
* Allows to use the default deserialize with the custom casper deserialize signature, defaulting encodeType to false
*
* @param deser the deserializer to be used
* @throws ValueDeserializationException exception holding information of failure to deserialize a value
*/
@Override
default void deserialize(DeserializerBuffer deser) throws ValueDeserializationException {
try {
deserialize(deser, Target.JSON);
} catch (NoSuchTypeException e) {
throw new ValueDeserializationException(String.format("Error deserializing %s", this.getClass().getSimpleName()), e);
}
}
}