Skip to content

Commit 04a5110

Browse files
committed
Refactor field type repr
1 parent f16c048 commit 04a5110

File tree

8 files changed

+195
-105
lines changed

8 files changed

+195
-105
lines changed

protobuf/lib/src/protobuf/builder_info.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class BuilderInfo {
7373
{ProtobufEnum? defaultEnumValue,
7474
String? protoName}) {
7575
var index = byIndex.length;
76-
_addField(MapFieldInfo<K, V>(name, tagNumber, index, const FieldType.MAP(),
76+
_addField(MapFieldInfo<K, V>(name, tagNumber, index, FieldType.map(),
7777
keyFieldType, valueFieldType, mapEntryBuilderInfo, valueCreator,
7878
defaultEnumValue: defaultEnumValue, protoName: protoName));
7979
}
@@ -124,36 +124,36 @@ class BuilderInfo {
124124
/// Adds PbFieldType.OS String with no default value to reduce generated
125125
/// code size.
126126
void aOS(int tagNumber, String name, {String? protoName}) {
127-
add<String>(tagNumber, name, const FieldType.OPTIONAL_STRING(), null, null,
128-
null, null,
127+
add<String>(
128+
tagNumber, name, FieldType.optional_string(), null, null, null, null,
129129
protoName: protoName);
130130
}
131131

132132
/// Adds PbFieldType.PS String with no default value.
133133
void pPS(int tagNumber, String name, {String? protoName}) {
134-
addRepeated<String>(tagNumber, name, const FieldType.REPEATED_STRING(),
135-
getCheckFunction(const FieldType.REPEATED_STRING()), null, null, null,
134+
addRepeated<String>(tagNumber, name, FieldType.repeated_string(),
135+
getCheckFunction(FieldType.repeated_string()), null, null, null,
136136
protoName: protoName);
137137
}
138138

139139
/// Adds PbFieldType.QS String with no default value.
140140
void aQS(int tagNumber, String name, {String? protoName}) {
141-
add<String>(tagNumber, name, const FieldType.REQUIRED_STRING(), null, null,
142-
null, null,
141+
add<String>(
142+
tagNumber, name, FieldType.required_string(), null, null, null, null,
143143
protoName: protoName);
144144
}
145145

146146
/// Adds Int64 field with Int64.ZERO default.
147147
void aInt64(int tagNumber, String name, {String? protoName}) {
148-
add<Int64>(tagNumber, name, const FieldType.OPTIONAL_I64(), Int64.ZERO,
149-
null, null, null,
148+
add<Int64>(
149+
tagNumber, name, FieldType.optional_i64(), Int64.ZERO, null, null, null,
150150
protoName: protoName);
151151
}
152152

153153
/// Adds a boolean with no default value.
154154
void aOB(int tagNumber, String name, {String? protoName}) {
155-
add<bool>(tagNumber, name, const FieldType.OPTIONAL_BOOL(), null, null,
156-
null, null,
155+
add<bool>(
156+
tagNumber, name, FieldType.optional_bool(), null, null, null, null,
157157
protoName: protoName);
158158
}
159159

@@ -195,7 +195,7 @@ class BuilderInfo {
195195
add<T>(
196196
tagNumber,
197197
name,
198-
const FieldType.OPTIONAL_MESSAGE(),
198+
FieldType.optional_message(),
199199
GeneratedMessage._defaultMakerFor<T>(subBuilder),
200200
subBuilder,
201201
null,
@@ -208,7 +208,7 @@ class BuilderInfo {
208208
add<T>(
209209
tagNumber,
210210
name,
211-
const FieldType.REQUIRED_MESSAGE(),
211+
FieldType.required_message(),
212212
GeneratedMessage._defaultMakerFor<T>(subBuilder),
213213
subBuilder,
214214
null,

protobuf/lib/src/protobuf/field_info.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class FieldInfo<T> {
126126

127127
bool get isRequired => type.isRequired;
128128
bool get isRepeated => type.isRepeated;
129-
bool get isGroupOrMessage => type.isGroup || type.isMessage;
129+
bool get isGroupOrMessage => type.isGroupOrMessage;
130130
bool get isEnum => type.isEnum;
131131
bool get isMapField => type.isMap;
132132

0 commit comments

Comments
 (0)