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

org.jetlinks.rule.engine.defaults.codec.BytesCodec Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package org.jetlinks.rule.engine.defaults.codec;

import io.netty.buffer.Unpooled;
import org.jetlinks.rule.engine.api.Payload;
import org.jetlinks.rule.engine.api.codec.Codec;

import javax.annotation.Nonnull;

public class BytesCodec implements Codec {

    public static BytesCodec INSTANCE = new BytesCodec();

    private BytesCodec() {

    }

    @Override
    public byte[] decode(@Nonnull Payload payload) {
        return payload.bodyAsBytes();
    }

    @Override
    public Payload encode(byte[] body) {
        return () -> Unpooled.wrappedBuffer(body);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy