All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jn.agileway.codec.Codec Maven / Gradle / Ivy

Go to download

Provide an unified codec API for hession, kryo, protostuff, fst, fes, xson, cbor, jackson, json, etc....

There is a newer version: 3.1.12
Show newest version
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