com.jn.agileway.codec.Codec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agileway-codec Show documentation
Show all versions of agileway-codec Show documentation
Provide an unified codec API for hession, kryo, protostuff, fst, fes, xson, cbor, jackson, json, etc....
package com.jn.agileway.codec;
import com.jn.langx.annotation.NonNull;
import com.jn.langx.annotation.Nullable;
import com.jn.langx.codec.CodecException;
import com.jn.langx.codec.ICodec;
public interface Codec extends ICodec {
/**
* 序列化
* @param t
* @return
* @throws CodecException
*/
@Override
byte[] encode(T t) throws CodecException;
/**
* 反序列化
* @param bytes
* @return
* @throws CodecException
*/
@Override
T decode(byte[] bytes) throws CodecException;
/**
* 按照指定的类型反序列化,
*
* @param bytes
* @param targetType
* @return
* @throws CodecException
*/
@Nullable
T decode(@Nullable byte[] bytes,@NonNull Class targetType) throws CodecException;
boolean canSerialize(Class> type);
Class getTargetType();
void setTargetType(Class expectedTargetType);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy