org.redkalex.convert.protobuf.ProtobufMapDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redkale-plugins Show documentation
Show all versions of redkale-plugins Show documentation
Redkale-Plugins -- java framework
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkalex.convert.protobuf;
import java.lang.reflect.Type;
import org.redkale.convert.*;
/**
*
* @author zhangjx
* @param K
* @param V
*/
public class ProtobufMapDecoder extends MapDecoder {
private final boolean enumtostring;
public ProtobufMapDecoder(ConvertFactory factory, Type type) {
super(factory, type);
this.enumtostring = ((ProtobufFactory) factory).enumtostring;
}
@Override
protected Reader getEntryReader(Reader in, DeMember member, boolean first) {
ProtobufReader reader = (ProtobufReader) in;
if (!first && member != null) {
int tag = reader.readTag();
if (tag != member.getTag()) {
reader.backTag(tag);
return null;
}
}
byte[] bs = reader.readByteArray();
return new ProtobufReader(bs);
}
@Override
protected K readKeyMember(Reader in, DeMember member, Decodeable decoder, boolean first) {
ProtobufReader reader = (ProtobufReader) in;
reader.readTag();
return decoder.convertFrom(in);
}
@Override
protected V readValueMember(Reader in, DeMember member, Decodeable decoder, boolean first) {
ProtobufReader reader = (ProtobufReader) in;
reader.readTag();
return decoder.convertFrom(in);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy