mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-18 04:28:40 +00:00
perf[ts]: remove null type of ts variable
This commit is contained in:
@@ -481,6 +481,13 @@ public class ProtocolAnalysis {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 此方法仅在生成协议的时候调用,一旦运行,不能调用
|
||||
*/
|
||||
public static Set<Short> getFirstSubProtocolIds(short protocolId) {
|
||||
return subProtocolIdMap.get(protocolId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 此方法仅在生成协议的时候调用,一旦运行,不能调用
|
||||
*/
|
||||
|
||||
@@ -137,7 +137,7 @@ public abstract class GenerateTsUtils {
|
||||
|
||||
private static String importSubProtocol(ProtocolRegistration registration) {
|
||||
var protocolId = registration.getId();
|
||||
var subProtocols = ProtocolAnalysis.getAllSubProtocolIds(protocolId);
|
||||
var subProtocols = ProtocolAnalysis.getFirstSubProtocolIds(protocolId);
|
||||
|
||||
if (CollectionUtils.isEmpty(subProtocols)) {
|
||||
return StringUtils.EMPTY;
|
||||
|
||||
+2
-2
@@ -33,8 +33,8 @@ public class TsArraySerializer implements ITsSerializer {
|
||||
|
||||
@Override
|
||||
public Triple<String, String, String> field(Field field, IFieldRegistration fieldRegistration) {
|
||||
var type = StringUtils.format(": Array<{}> | null", GenerateTsUtils.toTsClassName(field.getType().getComponentType().getSimpleName()));
|
||||
return new Triple<>(type, field.getName(), "null");
|
||||
var type = StringUtils.format(": Array<{}>", GenerateTsUtils.toTsClassName(field.getType().getComponentType().getSimpleName()));
|
||||
return new Triple<>(type, field.getName(), "[]");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -33,8 +33,8 @@ public class TsListSerializer implements ITsSerializer {
|
||||
|
||||
@Override
|
||||
public Triple<String, String, String> field(Field field, IFieldRegistration fieldRegistration) {
|
||||
var type = StringUtils.format(": {} | null", GenerateTsUtils.toTsClassName(field.getGenericType().toString()));
|
||||
return new Triple<>(type, field.getName(), "null");
|
||||
var type = StringUtils.format(": {}", GenerateTsUtils.toTsClassName(field.getGenericType().toString()));
|
||||
return new Triple<>(type, field.getName(), "[]");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,8 +33,8 @@ public class TsMapSerializer implements ITsSerializer {
|
||||
|
||||
@Override
|
||||
public Triple<String, String, String> field(Field field, IFieldRegistration fieldRegistration) {
|
||||
var type = StringUtils.format(": {} | null", GenerateTsUtils.toTsClassName(field.getGenericType().toString()));
|
||||
return new Triple<>(type, field.getName(), "null");
|
||||
var type = StringUtils.format(": {}", GenerateTsUtils.toTsClassName(field.getGenericType().toString()));
|
||||
return new Triple<>(type, field.getName(), "new Map()");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,8 +33,8 @@ public class TsSetSerializer implements ITsSerializer {
|
||||
|
||||
@Override
|
||||
public Triple<String, String, String> field(Field field, IFieldRegistration fieldRegistration) {
|
||||
var type = StringUtils.format(": {} | null", GenerateTsUtils.toTsClassName(field.getGenericType().toString()));
|
||||
return new Triple<>(type, field.getName(), "null");
|
||||
var type = StringUtils.format(": {}", GenerateTsUtils.toTsClassName(field.getGenericType().toString()));
|
||||
return new Triple<>(type, field.getName(), "new Set()");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,20 +4,16 @@ class {} {
|
||||
|
||||
{}
|
||||
|
||||
static PROTOCOL_ID: number = {}
|
||||
static PROTOCOL_ID: number = {};
|
||||
|
||||
protocolId(): number {
|
||||
return {}.PROTOCOL_ID;
|
||||
}
|
||||
|
||||
static write(buffer: any, packet: {} | null) {
|
||||
if (buffer.writePacketFlag(packet)) {
|
||||
if (buffer.writePacketFlag(packet) || packet == null) {
|
||||
return;
|
||||
}
|
||||
if (packet === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user