org.redkalex.convert.pson.ProtobufMapDecoder Maven / Gradle / Ivy
/*
* 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.pson;
import java.lang.reflect.Type;
import org.redkale.convert.*;
/**
*
* @author zhangjx
* @param K
* @param V
*/
public class ProtobufMapDecoder extends MapDecoder {
public ProtobufMapDecoder(ConvertFactory factory, Type type) {
super(factory, type);
}
@Override
protected Reader getEntryReader(Reader in, DeMember member, boolean first) {
ProtobufReader reader = (ProtobufReader) in;
if (!first && member != null) {
int tag = reader.readTag();
if (tag != ProtobufFactory.getTag(member)) {
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