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

net.dongliu.prettypb.runtime.code.ProtoInfo Maven / Gradle / Ivy

There is a newer version: 0.3.5
Show newest version
package net.dongliu.prettypb.runtime.code;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * proto type infos
 *
 * @author Dong Liu
 */
public class ProtoInfo {

    private Class clazz;
    private List protoFieldInfoList;
    private Map protoFieldInfoMap;

    public void addProtoFieldInfos(List protoFieldInfoList) {
        this.protoFieldInfoList = protoFieldInfoList;
        protoFieldInfoMap = new HashMap<>();
        for (ProtoFieldInfo pfi : protoFieldInfoList) {
            protoFieldInfoMap.put(pfi.idx(), pfi);
        }
    }

    public void setClazz(Class clazz) {
        this.clazz = clazz;
    }

    public Class getClazz() {
        return this.clazz;
    }

    /**
     * get the class's name
     *
     * @return
     */
    public String getName() {
        return clazz.getName();
    }

    public List getProtoFieldInfos() {
        return protoFieldInfoList;
    }

    public ProtoFieldInfo getProtoFieldInfo(int idx) {
        return protoFieldInfoMap.get(idx);
    }

    @Override
    public String toString() {
        return getName();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy