perf[module]: Event和protocol模块注释

This commit is contained in:
jianan committed 2022-07-03 22:50:26 +08:00
1 parent e4d3945142
commit 036ba4885c
5 files changed
+35 -1

No files matched your search

@@ -33,9 +33,19 @@ public class ProtocolManager {
public static final short MAX_PROTOCOL_NUM = Short.MAX_VALUE;
public static final byte MAX_MODULE_NUM = Byte.MAX_VALUE;
/**
* 索引:协议号protocolId
*/
public static final IProtocolRegistration[] protocols = new IProtocolRegistration[MAX_PROTOCOL_NUM];
/**
* 索引:模块号
*/
public static final ProtocolModule[] modules = new ProtocolModule[MAX_MODULE_NUM];
/**
* key:协议class
* value:protocolId
*/
private static final Map<Class<?>, Short> protocolIdMap = new HashMap<>();
static {
@@ -68,12 +78,24 @@ public class ProtocolManager {
return modules[protocols[id].module()];
}
/**
* 根据模块id查找模块
*
* @param moduleId
* @return
*/
public static ProtocolModule moduleByModuleId(byte moduleId) {
var module = modules[moduleId];
AssertionUtils.notNull(module, "[moduleId:{}]不存在", moduleId);
return module;
}
/**
* 根据模块名字查找模块
*
* @param name
* @return
*/
public static ProtocolModule moduleByModuleName(String name) {
var moduleOptional = Arrays.stream(modules)
.filter(it -> Objects.nonNull(it))
@@ -47,7 +47,7 @@ public class GenerateOperation {
private String protocolParam;
/**
* 需要生成的协议文件
* 需要生成的协议文件(c#、js、ts...等需要生成协议的语言都列出来)
*/
private final Set<CodeLanguage> generateLanguages = EnumSet.noneOf(CodeLanguage.class);
@@ -58,6 +58,13 @@ public abstract class GenerateProtocolFile {
index = null;
}
/**
* 生成各种语言的协议文件
*
* @param generateOperation
* @throws IOException
* @throws ClassNotFoundException
*/
public static void generate(GenerateOperation generateOperation) throws IOException, ClassNotFoundException {
var protocols = ProtocolManager.protocols;