
com.yinxiang.utils.thrift.grpc.infos.FileInfo Maven / Gradle / Ivy
package com.yinxiang.utils.thrift.grpc.infos;
import com.google.common.collect.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Record a proto file infos.
* @author Huiyuan Fu
* @since 1.0.0
*/
public class FileInfo {
/** The name of file. */
private String name;
/** The map of this proto's all struct, key is {@link StructInfo#getName()}. */
private Map structInfos = Maps.newLinkedHashMap();
/** The list of this proto's all services. */
private List serviceInfos = Lists.newLinkedList();
/** The set of this proto's all import. */
private Set imports = Sets.newHashSet();
/** The proto version, default 3. */
private byte version = 3;
/**
* The set of all struct origin name.
*
* In a proto file some struct will have same name, so with create struct the name will replace by a alias name,
* so need record the origin name to tell struct need replace it's name when has same name.
*
*/
private transient Set originNames = Sets.newHashSet();
/** The set of import this proto's proto name. */
private transient Set dependencyMe = Sets.newHashSet();
/** The map of dependencies, key is struct name, value is a set of dependencies proto name. */
private transient SetMultimap dependencies = HashMultimap.create();
public FileInfo(String name) {
this.name = name;
}
/** @see #name */
public String getName() {
return name;
}
/** @see #structInfos */
public Map getStructInfos() {
return structInfos;
}
/** @see #serviceInfos */
public List getServiceInfos() {
return serviceInfos;
}
/** @see #imports */
public Set getImports() {
return imports;
}
/** @see #imports */
public void setImports(Set imports) {
this.imports = imports;
}
/** @see #originNames */
public Set getOriginNames() {
return originNames;
}
/** @see #dependencyMe */
public Set getDependencyMe() {
return dependencyMe;
}
/** @see #dependencies */
public SetMultimap getDependencies() {
return dependencies;
}
/** @see #version */
public byte getVersion() {
return version;
}
/** @see #version */
public void setVersion(byte version) {
this.version = version;
}
/**
* Record a struct.
* @param structInfo struct
*/
public void saveStruct(StructInfo structInfo) {
structInfos.put(structInfo.getName(), structInfo);
originNames.add(structInfo.getOriginName());
structInfo.setFileInfo(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy