@@ -857,7 +857,6 @@ private void generateChoiceEncodeDecode(final StringBuilder sb, final String cho
857
857
{
858
858
final char varName = Character .toLowerCase (choiceName .charAt (0 ));
859
859
860
- // Encode
861
860
generateEncodeHeader (sb , varName , choiceName , false , false );
862
861
863
862
sb .append (String .format (
@@ -1191,30 +1190,21 @@ private int generateGroupEncodeDecode(
1191
1190
encode .append (generateEncodeOffset (gap , "" ));
1192
1191
decode .append (generateDecodeOffset (gap , "" ));
1193
1192
1194
- // Write block length
1195
1193
final String encBlockLengthTmpl =
1196
1194
"\t var %7$sBlockLength %1$s = %2$d\n " +
1197
1195
"\t if err := _m.Write%6$s(_w, %7$sBlockLength); err != nil {\n " +
1198
1196
"\t \t return err\n " +
1199
1197
"\t }\n " ;
1200
1198
1201
- // Write number of elements in group
1202
1199
final String encNumInGroupTmpl =
1203
1200
"\t var %7$sNumInGroup %3$s = %3$s(len(%4$s.%5$s))\n " +
1204
1201
"\t if err := _m.Write%8$s(_w, %7$sNumInGroup); err != nil {\n " +
1205
1202
"\t \t return err\n " +
1206
1203
"\t }\n " ;
1207
1204
1208
1205
// Order write based on offset
1209
- String encGrpMetaTmpl = "\n " ;
1210
- if (blockLengthOffset < numInGroupOffset )
1211
- {
1212
- encGrpMetaTmpl = encBlockLengthTmpl + encNumInGroupTmpl ;
1213
- }
1214
- else
1215
- {
1216
- encGrpMetaTmpl = encNumInGroupTmpl + encBlockLengthTmpl ;
1217
- }
1206
+ final String encGrpMetaTmpl = blockLengthOffset < numInGroupOffset ?
1207
+ encBlockLengthTmpl + encNumInGroupTmpl : encNumInGroupTmpl + encBlockLengthTmpl ;
1218
1208
1219
1209
encode .append (String .format (encGrpMetaTmpl ,
1220
1210
blockLengthType ,
@@ -1235,43 +1225,28 @@ private int generateGroupEncodeDecode(
1235
1225
varName ,
1236
1226
toUpperFirstChar (signalToken .name ())));
1237
1227
1238
- // Check version
1239
1228
decode .append (String .format (
1240
1229
"\n " +
1241
1230
"\t if %1$s.%2$sInActingVersion(actingVersion) {\n " ,
1242
1231
varName ,
1243
- propertyName ,
1244
- blockLengthType ,
1245
- numInGroupType ,
1246
- blockLengthMarshalType ,
1247
- numInGroupMarshalType ));
1232
+ propertyName ));
1248
1233
1249
- // Read block length
1250
1234
final String decBlockLengthTmpl =
1251
- "\t \t var %2 $sBlockLength %3 $s\n " +
1252
- "\t \t if err := _m.Read%5 $s(_r, &%2 $sBlockLength); err != nil {\n " +
1235
+ "\t \t var %1 $sBlockLength %2 $s\n " +
1236
+ "\t \t if err := _m.Read%4 $s(_r, &%1 $sBlockLength); err != nil {\n " +
1253
1237
"\t \t \t return err\n " +
1254
1238
"\t \t }\n " ;
1255
1239
1256
- // Read number of elements in group
1257
1240
final String decNumInGroupTmpl =
1258
- "\t \t var %2 $sNumInGroup %4 $s\n " +
1259
- "\t \t if err := _m.Read%6 $s(_r, &%2 $sNumInGroup); err != nil {\n " +
1241
+ "\t \t var %1 $sNumInGroup %3 $s\n " +
1242
+ "\t \t if err := _m.Read%5 $s(_r, &%1 $sNumInGroup); err != nil {\n " +
1260
1243
"\t \t \t return err\n " +
1261
1244
"\t \t }\n " ;
1262
1245
1263
- // Order read based on offset
1264
- String decGrpMetaTmpl = "\n " ;
1265
- if (blockLengthOffset < numInGroupOffset )
1266
- {
1267
- decGrpMetaTmpl = decBlockLengthTmpl + decNumInGroupTmpl ;
1268
- }
1269
- else
1270
- {
1271
- decGrpMetaTmpl = decNumInGroupTmpl + decBlockLengthTmpl ;
1272
- }
1246
+ final String decGrpMetaTmpl = blockLengthOffset < numInGroupOffset ?
1247
+ decBlockLengthTmpl + decNumInGroupTmpl : decNumInGroupTmpl + decBlockLengthTmpl ;
1248
+
1273
1249
decode .append (String .format (decGrpMetaTmpl ,
1274
- varName ,
1275
1250
propertyName ,
1276
1251
blockLengthType ,
1277
1252
numInGroupType ,
@@ -1818,15 +1793,10 @@ private void generateCompositePropertyElements(
1818
1793
final String propertyName = formatPropertyName (token .name ());
1819
1794
1820
1795
// Write {Min,Max,Null}Value
1821
- switch (token .signal ())
1796
+ if (token .signal () == Signal . ENCODING )
1822
1797
{
1823
- case ENCODING :
1824
- generateMinMaxNull (sb , containingTypeName , propertyName , token );
1825
- generateCharacterEncoding (sb , containingTypeName , propertyName , token );
1826
- break ;
1827
-
1828
- default :
1829
- break ;
1798
+ generateMinMaxNull (sb , containingTypeName , propertyName , token );
1799
+ generateCharacterEncoding (sb , containingTypeName , propertyName , token );
1830
1800
}
1831
1801
1832
1802
switch (token .signal ())
@@ -1837,6 +1807,7 @@ private void generateCompositePropertyElements(
1837
1807
case BEGIN_COMPOSITE :
1838
1808
generateSinceActingDeprecated (sb , containingTypeName , propertyName , token );
1839
1809
break ;
1810
+
1840
1811
default :
1841
1812
break ;
1842
1813
}
0 commit comments