net.dongliu.prettypb.runtime.code.ProtoInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prettypb-runtime Show documentation
Show all versions of prettypb-runtime Show documentation
Prettypb serialization runtime
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();
}
}