Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
top.netkit.redis.client.codec.CustomCodec Maven / Gradle / Ivy
package top.netkit.redis.client.codec;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.codec.TypedJsonJacksonCodec;
import java.io.IOException;
/**
* 自定义customCodec
* @author shixinke
*/
public class CustomCodec extends TypedJsonJacksonCodec {
private final Decoder decoder = new Decoder() {
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
String str = buf.toString(CharsetUtil.UTF_8);
buf.readerIndex(buf.readableBytes());
return str;
}
};
public CustomCodec(Class> valueClass) {
super(valueClass);
}
public CustomCodec(Class> valueClass, ObjectMapper mapper) {
super(valueClass, mapper);
}
public CustomCodec(Class> mapKeyClass, Class> mapValueClass) {
super(mapKeyClass, mapValueClass);
}
public CustomCodec(Class> mapKeyClass, Class> mapValueClass, ObjectMapper mapper) {
super(mapKeyClass, mapValueClass, mapper);
}
public CustomCodec(Class> valueClass, Class> mapKeyClass, Class> mapValueClass) {
super(valueClass, mapKeyClass, mapValueClass);
}
public CustomCodec(Class> valueClass, Class> mapKeyClass, Class> mapValueClass, ObjectMapper mapper) {
super(valueClass, mapKeyClass, mapValueClass, mapper);
}
public CustomCodec(TypeReference> valueTypeReference) {
super(valueTypeReference);
}
public CustomCodec(TypeReference> valueTypeReference, ObjectMapper mapper) {
super(valueTypeReference, mapper);
}
public CustomCodec(TypeReference> mapKeyTypeReference, TypeReference> mapValueTypeReference) {
super(mapKeyTypeReference, mapValueTypeReference);
}
public CustomCodec(TypeReference> mapKeyTypeReference, TypeReference> mapValueTypeReference, ObjectMapper mapper) {
super(mapKeyTypeReference, mapValueTypeReference, mapper);
}
public CustomCodec(TypeReference> valueTypeReference, TypeReference> mapKeyTypeReference, TypeReference> mapValueTypeReference) {
super(valueTypeReference, mapKeyTypeReference, mapValueTypeReference);
}
public CustomCodec(TypeReference> valueTypeReference, TypeReference> mapKeyTypeReference, TypeReference> mapValueTypeReference, ObjectMapper mapper) {
super(valueTypeReference, mapKeyTypeReference, mapValueTypeReference, mapper);
}
public CustomCodec(ClassLoader classLoader, TypedJsonJacksonCodec codec) {
super(classLoader, codec);
}
@Override
public Decoder getMapKeyDecoder() {
return decoder;
}
}