@@ -2379,8 +2379,7 @@ private CharSequence generateCompositeDecoderDisplay(final List<Token> tokens, f
23792379 sb .append ('\n' );
23802380 append (sb , indent , "public StringBuilder appendTo(final StringBuilder builder)" );
23812381 append (sb , indent , "{" );
2382- append (sb , indent , " builder.append(\" [\" );" );
2383-
2382+ Separators .BEGIN_COMPOSITE .appendToGeneratedBuilder (sb , indent + INDENT , "builder" );
23842383 for (int i = 1 , end = tokens .size () - 1 ; i < end ; )
23852384 {
23862385 final Token encodingToken = tokens .get (i );
@@ -2389,8 +2388,7 @@ private CharSequence generateCompositeDecoderDisplay(final List<Token> tokens, f
23892388 i += encodingToken .componentTokenCount ();
23902389 }
23912390
2392- append (sb , indent , " builder.setLength(builder.length() - 1);" );
2393- append (sb , indent , " builder.append(\" ]\" );" );
2391+ Separators .END_COMPOSITE .appendToGeneratedBuilder (sb , indent + INDENT , "builder" );
23942392 sb .append ('\n' );
23952393 append (sb , indent , " return builder;" );
23962394 append (sb , indent , "}" );
@@ -2407,7 +2405,7 @@ private CharSequence generateChoiceDisplay(final List<Token> tokens)
24072405 sb .append ('\n' );
24082406 append (sb , indent , "public StringBuilder appendTo(final StringBuilder builder)" );
24092407 append (sb , indent , "{" );
2410- append (sb , indent , " builder.append('{'); " );
2408+ Separators . BEGIN_SET . appendToGeneratedBuilder (sb , indent + INDENT , " builder" );
24112409 append (sb , indent , " boolean atLeastOne = false;" );
24122410
24132411 tokens
@@ -2421,15 +2419,15 @@ private CharSequence generateChoiceDisplay(final List<Token> tokens)
24212419 append (sb , indent , " {" );
24222420 append (sb , indent , " if (atLeastOne)" );
24232421 append (sb , indent , " {" );
2424- append (sb , indent , " builder.append(','); " );
2422+ Separators . ENTRY . appendToGeneratedBuilder (sb , indent + INDENT + INDENT + INDENT , " builder" );
24252423 append (sb , indent , " }" );
24262424 append (sb , indent , " builder.append(\" " + choiceName + "\" );" );
24272425 append (sb , indent , " atLeastOne = true;" );
24282426 append (sb , indent , " }" );
24292427 }
24302428 );
24312429
2432- append (sb , indent , " builder.append('}'); " );
2430+ Separators . END_SET . appendToGeneratedBuilder (sb , indent + INDENT , " builder" );
24332431 sb .append ('\n' );
24342432 append (sb , indent , " return builder;" );
24352433 append (sb , indent , "}" );
@@ -2497,8 +2495,9 @@ private StringBuilder appendGroupInstanceDecoderDisplay(
24972495 sb .append ('\n' );
24982496 append (sb , indent , "public StringBuilder appendTo(final StringBuilder builder)" );
24992497 append (sb , indent , "{" );
2498+ Separators .BEGIN_COMPOSITE .appendToGeneratedBuilder (sb , indent + INDENT , "builder" );
25002499 appendDecoderDisplay (sb , fields , groups , varData , indent + INDENT );
2501- sb . append ( '\n' );
2500+ Separators . END_COMPOSITE . appendToGeneratedBuilder ( sb , indent + INDENT , "builder" );
25022501 append (sb , indent , " return builder;" );
25032502 append (sb , indent , "}" );
25042503
@@ -2534,16 +2533,15 @@ private StringBuilder appendDecoderDisplay(
25342533 final String groupName = formatPropertyName (groupToken .name ());
25352534 final String groupDecoderName = decoderName (formatClassName (groupToken .name ()));
25362535
2537- append (sb , indent , "builder.append(\" " + groupName + "={ \" );" );
2536+ append (sb , indent , "builder.append(\" " + groupName + Separators . KEY_VALUE + Separators . BEGIN_GROUP + " \" );" );
25382537 append (sb , indent , groupDecoderName + " " + groupName + " = " + groupName + "();" );
25392538 append (sb , indent , "while (" + groupName + ".hasNext())" );
25402539 append (sb , indent , "{" );
2541- append (sb , indent , " builder.append('[');" );
25422540 append (sb , indent , " " + groupName + ".next().appendTo(builder);" );
2543- append (sb , indent , " builder.setLength(builder.length() - 1);" );
2544- append (sb , indent , " builder.append(']');" );
2541+ Separators .ENTRY .appendToGeneratedBuilder (sb , indent + INDENT , "builder" );
25452542 append (sb , indent , "}" );
2546- append (sb , indent , "builder.append(\" }|\" );" );
2543+ append (sb , indent , "builder.setLength(builder.length() - 1);" );
2544+ append (sb , indent , "builder.append(\" " + Separators .END_GROUP + Separators .FIELD + "\" );" );
25472545
25482546 i = findEndSignal (groups , i , Signal .END_GROUP , groupToken .name ());
25492547 }
@@ -2559,9 +2557,9 @@ private StringBuilder appendDecoderDisplay(
25592557 append (sb , indent , "//" + varDataToken );
25602558
25612559 final String varDataName = formatPropertyName (varDataToken .name ());
2562- append (sb , indent , "builder.append(\" " + varDataName + "= \" );" );
2560+ append (sb , indent , "builder.append(\" " + varDataName + Separators . KEY_VALUE + " \" );" );
25632561 append (sb , indent , "builder.append(" + varDataName + "());" );
2564- append (sb , indent , "builder.append('|'); " );
2562+ Separators . FIELD . appendToGeneratedBuilder (sb , indent , "builder" );
25652563
25662564 i += varDataToken .componentTokenCount ();
25672565 }
@@ -2582,7 +2580,7 @@ private void writeTokenDisplay(
25822580 return ;
25832581 }
25842582
2585- append (sb , indent , "builder.append(\" " + fieldName + "= \" );" );
2583+ append (sb , indent , "builder.append(\" " + fieldName + Separators . KEY_VALUE + " \" );" );
25862584
25872585 switch (typeToken .signal ())
25882586 {
@@ -2598,16 +2596,17 @@ private void writeTokenDisplay(
25982596 }
25992597 else
26002598 {
2601- append (sb , indent , "builder.append('['); " );
2599+ Separators . BEGIN_ARRAY . appendToGeneratedBuilder (sb , indent , "builder" );
26022600 append (sb , indent , "if (" + fieldName + "Length() > 0)" );
26032601 append (sb , indent , "{" );
26042602 append (sb , indent , " for (int i = 0; i < " + fieldName + "Length(); i++)" );
26052603 append (sb , indent , " {" );
2606- append (sb , indent , " builder.append(" + fieldName + "(i)).append(',');" );
2604+ append (sb , indent , " builder.append(" + fieldName + "(i));" );
2605+ Separators .ENTRY .appendToGeneratedBuilder (sb , indent + INDENT + INDENT , "builder" );
26072606 append (sb , indent , " }" );
26082607 append (sb , indent , " builder.setLength(builder.length()-1);" );
26092608 append (sb , indent , "}" );
2610- append (sb , indent , "builder.append(']'); " );
2609+ Separators . END_ARRAY . appendToGeneratedBuilder (sb , indent , "builder" );
26112610 }
26122611 }
26132612 else
@@ -2627,7 +2626,7 @@ private void writeTokenDisplay(
26272626 break ;
26282627 }
26292628
2630- append (sb , indent , "builder.append('|'); " );
2629+ Separators . FIELD . appendToGeneratedBuilder (sb , indent , "builder" );
26312630 }
26322631
26332632 private void appendToString (final StringBuilder sb , final String indent )
0 commit comments