diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/CodeGenerateEcmaScript.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/CodeGenerateEcmaScript.java index 0c28c9c34..abe1c83aa 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/CodeGenerateEcmaScript.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/CodeGenerateEcmaScript.java @@ -253,8 +253,8 @@ private String protocol_field_definition(ProtocolRegistration registration) { for (var fieldNote : fieldNotes) { fieldDefinitionBuilder.append(fieldNote).append(LS); } - var triple = esSerializer(fieldRegistration.serializer()).field(field, fieldRegistration); - fieldDefinitionBuilder.append(StringUtils.format("{} = {}; // {}", fieldName, triple.getRight(), triple.getLeft())) + var fieldTypeValue = esSerializer(fieldRegistration.serializer()).fieldTypeValue(field, fieldRegistration); + fieldDefinitionBuilder.append(StringUtils.format("{} = {}; // {}", fieldName, fieldTypeValue.getValue(), fieldTypeValue.getKey())) .append(LS); } diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsArraySerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsArraySerializer.java index 97acfa8fa..1cb177709 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsArraySerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsArraySerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.ArrayField; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.serializer.CodeLanguage; @@ -31,9 +31,9 @@ */ public class EsArraySerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { var type = StringUtils.format("Array<{}>", CodeGenerateTypeScript.toTsClassName(field.getType().getComponentType().getSimpleName())); - return new Triple<>(type, field.getName(), "[]"); + return new Pair<>(type, "[]"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsBoolSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsBoolSerializer.java index bd11d3a43..916c6cca2 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsBoolSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsBoolSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsBoolSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("boolean", field.getName(), "false"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("boolean", "false"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsByteSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsByteSerializer.java index b72524d2f..8b4ecefab 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsByteSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsByteSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsByteSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("number", field.getName(), "0"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("number", "0"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsDoubleSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsDoubleSerializer.java index 483b313ff..84a91b370 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsDoubleSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsDoubleSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsDoubleSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("number", field.getName(), "0"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("number", "0"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsFloatSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsFloatSerializer.java index a7ebdf34d..1776fd1bf 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsFloatSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsFloatSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsFloatSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("number", field.getName(), "0"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("number", "0"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsIntSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsIntSerializer.java index 34975ae95..85c9268d7 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsIntSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsIntSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsIntSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("number", field.getName(), "0"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("number", "0"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsListSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsListSerializer.java index b41945b20..c15ee98ed 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsListSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsListSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.ListField; import com.zfoo.protocol.serializer.CodeLanguage; @@ -31,8 +31,8 @@ */ public class EsListSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>(CodeGenerateTypeScript.toTsClassName(field.getGenericType().toString()), field.getName(), "[]"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>(CodeGenerateTypeScript.toTsClassName(field.getGenericType().toString()), "[]"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsLongSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsLongSerializer.java index d6ef40ab2..3d393e043 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsLongSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsLongSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsLongSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("number", field.getName(), "0"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("number", "0"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsMapSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsMapSerializer.java index 975d78bd4..93dce28aa 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsMapSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsMapSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.MapField; import com.zfoo.protocol.serializer.CodeLanguage; @@ -31,8 +31,8 @@ */ public class EsMapSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>(CodeGenerateTypeScript.toTsClassName(field.getGenericType().toString()), field.getName(), "new Map()"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>(CodeGenerateTypeScript.toTsClassName(field.getGenericType().toString()), "new Map()"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsObjectProtocolSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsObjectProtocolSerializer.java index 52c3e98f3..0166b5122 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsObjectProtocolSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsObjectProtocolSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.ObjectProtocolField; import com.zfoo.protocol.serializer.enhance.EnhanceObjectProtocolSerializer; @@ -29,11 +29,11 @@ */ public class EsObjectProtocolSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { ObjectProtocolField objectProtocolField = (ObjectProtocolField) fieldRegistration; var protocolSimpleName = EnhanceObjectProtocolSerializer.getProtocolClassSimpleName(objectProtocolField.getProtocolId()); var type = StringUtils.format("{} | null", protocolSimpleName); - return new Triple<>(type, field.getName(), "null"); + return new Pair<>(type, "null"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsSetSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsSetSerializer.java index 7f98962f3..8f81b160b 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsSetSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsSetSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.registration.field.SetField; import com.zfoo.protocol.serializer.CodeLanguage; @@ -31,8 +31,8 @@ */ public class EsSetSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>(CodeGenerateTypeScript.toTsClassName(field.getGenericType().toString()), field.getName(), "new Set()"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>(CodeGenerateTypeScript.toTsClassName(field.getGenericType().toString()), "new Set()"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsShortSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsShortSerializer.java index 50b2976ee..38ebf910c 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsShortSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsShortSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsShortSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("number", field.getName(), "0"); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("number", "0"); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsStringSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsStringSerializer.java index 2999c22c9..25ac9f11e 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsStringSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/EsStringSerializer.java @@ -14,7 +14,7 @@ package com.zfoo.protocol.serializer.ecmascript; import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import com.zfoo.protocol.util.StringUtils; @@ -27,8 +27,8 @@ */ public class EsStringSerializer implements IEsSerializer { @Override - public Triple field(Field field, IFieldRegistration fieldRegistration) { - return new Triple<>("string", field.getName(), "\"\""); + public Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration) { + return new Pair<>("string", "\"\""); } @Override diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/IEsSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/IEsSerializer.java index be5709d7e..f2015b171 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/IEsSerializer.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/ecmascript/IEsSerializer.java @@ -13,7 +13,7 @@ package com.zfoo.protocol.serializer.ecmascript; -import com.zfoo.protocol.model.Triple; +import com.zfoo.protocol.model.Pair; import com.zfoo.protocol.registration.field.IFieldRegistration; import java.lang.reflect.Field; @@ -24,9 +24,9 @@ public interface IEsSerializer { /** - * 获取属性的类型,名称,默认值 + * 获取属性的类型,默认值 */ - Triple field(Field field, IFieldRegistration fieldRegistration); + Pair fieldTypeValue(Field field, IFieldRegistration fieldRegistration); void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration);