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

org.redkalex.convert.protobuf.ProtobufObjectEncoder Maven / Gradle / Ivy

There is a newer version: 2.7.7
Show newest version
/*
 * 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.*;
import org.redkale.util.Attribute;

/**
 *
 * @author zhangjx
 */
public class ProtobufObjectEncoder extends ObjectEncoder {

    protected ProtobufObjectEncoder(Type type) {
        super(type);
    }

    @Override
    protected void initForEachEnMember(ConvertFactory factory, EnMember member) {
        Attribute attr = member.getAttribute();
        setTag(member, ProtobufFactory.getTag(attr.field(), attr.genericType(), member.getPosition(), ((ProtobufFactory) factory).enumtostring));
    }

    @Override
    protected ProtobufWriter objectWriter(ProtobufWriter out, T value) {
        if (out.count() > out.initoffset) return new ProtobufWriter(out).configFieldFunc(out);
        return out; 
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy