Skip to content

Commit 060b6fb

Browse files
author
etienne-sf
committed
Issue #163 - replaced every StringBuffer by StringBuilder
1 parent 1522c82 commit 060b6fb

File tree

28 files changed

+125
-88
lines changed

28 files changed

+125
-88
lines changed

TODO.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Here are the next tasks listed, as a TODO list:
22

33

44
## TODO list for the current version
5+
* #164: Descriptions from the schema should be included in the generated code if they exist
6+
* In the generated classes the comments could be included to describe the different fields correctly instead of using "Parameter for the mapsAcqr field of query_root, as defined in the GraphQL schema" description string.
7+
* All comments are loaded in Description field and no longer in comment (graphql.language.Comment) fields when using java schema parser (graphql/graphql-js#927 and graphql/graphql-spec#420).
8+
* Update of all call to setComments in DocumentParser to load Descriptions instead of comments. Allow descriptions to be acessible in template files. Add descriptions to InputParameters if exist to be acessible to templaters.
59
* Document in the Client FAQ how to retrieve the extensions response's values
610
* Tutorial: add the documentation about the application.yml file
711
* Especially: `spring.main.web-application-type = none`

graphql-java-client-runtime/src/main/java/com/graphql_java_generator/client/RequestExecutionSpringReactiveImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ protected synchronized void initWebSocketConnection(GraphQLObjectMapper graphQLO
263263
logger.debug(GRAPHQL_MARKER, "Executing GraphQL web socket connection");
264264
if (logger.isTraceEnabled()) {
265265
// Let's log the sent headers
266-
StringBuffer sb = new StringBuffer();
266+
StringBuilder sb = new StringBuilder();
267267
sb.append("The Subscription GET request will be sent with these headers:\n");
268268
if (headers.entrySet().size() == 0) {
269269
sb.append(" ").append("<No headers!>");

graphql-java-client-runtime/src/main/java/com/graphql_java_generator/client/graphqlrepository/GraphQLRepositoryInvocationHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private void registerMethod(RegisteredMethod registeredMethod, Method method, bo
391391
registeredMethod.executorMethod = registeredMethod.executor.getClass()
392392
.getMethod(registeredMethod.executorMethodName, registeredMethod.executorParameterTypes);
393393
} catch (NoSuchMethodException | SecurityException e) {
394-
StringBuffer parameters = new StringBuffer();
394+
StringBuilder parameters = new StringBuilder();
395395
String separator = "";
396396
for (Class<?> clazz : registeredMethod.executorParameterTypes) {
397397
parameters.append(separator);

graphql-java-client-runtime/src/main/java/com/graphql_java_generator/client/request/InputParameter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public static List<InputParameter> readTokenizerForInputParameters(QueryTokenize
455455
// We've found the start of a JSON list or JSON object. Let's read this object.
456456
// We'll store it as a String, and write it back in the request toward the GraphQL server
457457
// request
458-
StringBuffer sb = new StringBuffer(token);
458+
StringBuilder sb = new StringBuilder(token);
459459
String previousToken;
460460
boolean list = token.startsWith("[");
461461
int listDepth = 0;
@@ -499,7 +499,7 @@ public static List<InputParameter> readTokenizerForInputParameters(QueryTokenize
499499
InputParameterType.GRAPHQL_VALUE, null, false, listDepth, false));
500500
} else if (token.equals("\"")) {
501501
// We've found a String value: let's read the string content
502-
StringBuffer sb = new StringBuffer("\"");
502+
StringBuilder sb = new StringBuilder("\"");
503503
boolean nextCharIsEscaped = false;
504504
while (true) {
505505
if (!qt.hasMoreTokens(true)) {

graphql-java-client-runtime/src/main/java/com/graphql_java_generator/client/response/Error.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class Error {
5555
*/
5656
@Override
5757
public String toString() {
58-
StringBuffer sb = new StringBuffer();
58+
StringBuilder sb = new StringBuilder();
5959

6060
if (validationErrorType != null) {
6161
sb.append("[{").append(validationErrorType).append("}]");

graphql-java-client-runtime/src/test/java/com/graphql_java_generator/domain/client/allGraphQLCases/AnotherMutationTypeExecutor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public AnotherMutationTypeResponse execWithBindValues(ObjectResponse objectRespo
252252
if (parameters == null) {
253253
logger.trace("Executing mutation without parameters");
254254
} else {
255-
StringBuffer sb = new StringBuffer("Executing root mutation with parameters: ");
255+
StringBuilder sb = new StringBuilder("Executing root mutation with parameters: ");
256256
boolean addComma = false;
257257
for (String key : parameters.keySet()) {
258258
sb.append(key).append(":").append(parameters.get(key));
@@ -526,7 +526,7 @@ public Human createHumanWithBindValues(ObjectResponse objectResponse, HumanInput
526526
public Human createHuman(ObjectResponse objectResponse, HumanInput human, Object... paramsAndValues)
527527
throws GraphQLRequestExecutionException {
528528
if (logger.isTraceEnabled()) {
529-
StringBuffer sb = new StringBuffer();
529+
StringBuilder sb = new StringBuilder();
530530
sb.append("Executing mutation 'createHuman' with bind variables: ");
531531
boolean addComma = false;
532532
for (Object o : paramsAndValues) {
@@ -767,7 +767,7 @@ public AllFieldCases createAllFieldCasesWithBindValues(ObjectResponse objectResp
767767
public AllFieldCases createAllFieldCases(ObjectResponse objectResponse, AllFieldCasesInput input,
768768
Object... paramsAndValues) throws GraphQLRequestExecutionException {
769769
if (logger.isTraceEnabled()) {
770-
StringBuffer sb = new StringBuffer();
770+
StringBuilder sb = new StringBuilder();
771771
sb.append("Executing mutation 'createAllFieldCases' with bind variables: ");
772772
boolean addComma = false;
773773
for (Object o : paramsAndValues) {
@@ -1010,7 +1010,7 @@ public Boolean deleteSnacksWithBindValues(ObjectResponse objectResponse, List<St
10101010
public Boolean deleteSnacks(ObjectResponse objectResponse, List<String> id, Object... paramsAndValues)
10111011
throws GraphQLRequestExecutionException {
10121012
if (logger.isTraceEnabled()) {
1013-
StringBuffer sb = new StringBuffer();
1013+
StringBuilder sb = new StringBuilder();
10141014
sb.append("Executing mutation 'deleteSnacks' with bind variables: ");
10151015
boolean addComma = false;
10161016
for (Object o : paramsAndValues) {
@@ -1240,7 +1240,7 @@ public String __typenameWithBindValues(ObjectResponse objectResponse, Map<String
12401240
public String __typename(ObjectResponse objectResponse, Object... paramsAndValues)
12411241
throws GraphQLRequestExecutionException {
12421242
if (logger.isTraceEnabled()) {
1243-
StringBuffer sb = new StringBuffer();
1243+
StringBuilder sb = new StringBuilder();
12441244
sb.append("Executing mutation '__typename' with bind variables: ");
12451245
boolean addComma = false;
12461246
for (Object o : paramsAndValues) {

graphql-java-client-runtime/src/test/java/com/graphql_java_generator/domain/client/allGraphQLCases/GraphQLRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private void logExecution(RequestType requestType, Map<String, Object> parameter
327327
if (parameters == null) {
328328
logger.trace("Executing of " + requestType.toString() + " without parameters");
329329
} else {
330-
StringBuffer sb = new StringBuffer("Executing of root mutation with parameters: ");
330+
StringBuilder sb = new StringBuilder("Executing of root mutation with parameters: ");
331331
boolean addComma = false;
332332
for (String key : parameters.keySet()) {
333333
sb.append(key).append(":").append(parameters.get(key));

graphql-java-client-runtime/src/test/java/com/graphql_java_generator/domain/client/allGraphQLCases/MyQueryTypeExecutor.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public MyQueryTypeResponse execWithBindValues(ObjectResponse objectResponse, Map
253253
if (parameters == null) {
254254
logger.trace("Executing query without parameters");
255255
} else {
256-
StringBuffer sb = new StringBuffer("Executing root query with parameters: ");
256+
StringBuilder sb = new StringBuilder("Executing root query with parameters: ");
257257
boolean addComma = false;
258258
for (String key : parameters.keySet()) {
259259
sb.append(key).append(":").append(parameters.get(key));
@@ -518,7 +518,7 @@ public List<Character> withoutParametersWithBindValues(ObjectResponse objectResp
518518
public List<Character> withoutParameters(ObjectResponse objectResponse, Object... paramsAndValues)
519519
throws GraphQLRequestExecutionException {
520520
if (logger.isTraceEnabled()) {
521-
StringBuffer sb = new StringBuffer();
521+
StringBuilder sb = new StringBuilder();
522522
sb.append("Executing query 'withoutParameters' with bind variables: ");
523523
boolean addComma = false;
524524
for (Object o : paramsAndValues) {
@@ -753,7 +753,7 @@ public Character withOneOptionalParamWithBindValues(ObjectResponse objectRespons
753753
public Character withOneOptionalParam(ObjectResponse objectResponse, CharacterInput character,
754754
Object... paramsAndValues) throws GraphQLRequestExecutionException {
755755
if (logger.isTraceEnabled()) {
756-
StringBuffer sb = new StringBuffer();
756+
StringBuilder sb = new StringBuilder();
757757
sb.append("Executing query 'withOneOptionalParam' with bind variables: ");
758758
boolean addComma = false;
759759
for (Object o : paramsAndValues) {
@@ -993,7 +993,7 @@ public Character withOneMandatoryParamWithBindValues(ObjectResponse objectRespon
993993
public Character withOneMandatoryParam(ObjectResponse objectResponse, CharacterInput character,
994994
Object... paramsAndValues) throws GraphQLRequestExecutionException {
995995
if (logger.isTraceEnabled()) {
996-
StringBuffer sb = new StringBuffer();
996+
StringBuilder sb = new StringBuilder();
997997
sb.append("Executing query 'withOneMandatoryParam' with bind variables: ");
998998
boolean addComma = false;
999999
for (Object o : paramsAndValues) {
@@ -1237,7 +1237,7 @@ public Integer withOneMandatoryParamDefaultValueWithBindValues(ObjectResponse ob
12371237
public Integer withOneMandatoryParamDefaultValue(ObjectResponse objectResponse, Integer intParam,
12381238
Object... paramsAndValues) throws GraphQLRequestExecutionException {
12391239
if (logger.isTraceEnabled()) {
1240-
StringBuffer sb = new StringBuffer();
1240+
StringBuilder sb = new StringBuilder();
12411241
sb.append("Executing query 'withOneMandatoryParamDefaultValue' with bind variables: ");
12421242
boolean addComma = false;
12431243
for (Object o : paramsAndValues) {
@@ -1495,7 +1495,7 @@ public Droid withTwoMandatoryParamDefaultValWithBindValues(ObjectResponse object
14951495
public Droid withTwoMandatoryParamDefaultVal(ObjectResponse objectResponse, DroidInput theHero, Integer num,
14961496
Object... paramsAndValues) throws GraphQLRequestExecutionException {
14971497
if (logger.isTraceEnabled()) {
1498-
StringBuffer sb = new StringBuffer();
1498+
StringBuilder sb = new StringBuilder();
14991499
sb.append("Executing query 'withTwoMandatoryParamDefaultVal' with bind variables: ");
15001500
boolean addComma = false;
15011501
for (Object o : paramsAndValues) {
@@ -1738,7 +1738,7 @@ public Character withEnumWithBindValues(ObjectResponse objectResponse, Episode e
17381738
public Character withEnum(ObjectResponse objectResponse, Episode episode, Object... paramsAndValues)
17391739
throws GraphQLRequestExecutionException {
17401740
if (logger.isTraceEnabled()) {
1741-
StringBuffer sb = new StringBuffer();
1741+
StringBuilder sb = new StringBuilder();
17421742
sb.append("Executing query 'withEnum' with bind variables: ");
17431743
boolean addComma = false;
17441744
for (Object o : paramsAndValues) {
@@ -1975,7 +1975,7 @@ public AllFieldCases withListOfListWithBindValues(ObjectResponse objectResponse,
19751975
public AllFieldCases withListOfList(ObjectResponse objectResponse, List<List<Double>> matrix,
19761976
Object... paramsAndValues) throws GraphQLRequestExecutionException {
19771977
if (logger.isTraceEnabled()) {
1978-
StringBuffer sb = new StringBuffer();
1978+
StringBuilder sb = new StringBuilder();
19791979
sb.append("Executing query 'withListOfList' with bind variables: ");
19801980
boolean addComma = false;
19811981
for (Object o : paramsAndValues) {
@@ -2224,7 +2224,7 @@ public List<Character> withListWithBindValues(ObjectResponse objectResponse, Str
22242224
public List<Character> withList(ObjectResponse objectResponse, String firstName, List<CharacterInput> characters,
22252225
Object... paramsAndValues) throws GraphQLRequestExecutionException {
22262226
if (logger.isTraceEnabled()) {
2227-
StringBuffer sb = new StringBuffer();
2227+
StringBuilder sb = new StringBuilder();
22282228
sb.append("Executing query 'withList' with bind variables: ");
22292229
boolean addComma = false;
22302230
for (Object o : paramsAndValues) {
@@ -2474,7 +2474,7 @@ public AllFieldCases allFieldCasesWithBindValues(ObjectResponse objectResponse,
24742474
public AllFieldCases allFieldCases(ObjectResponse objectResponse, AllFieldCasesInput input,
24752475
Object... paramsAndValues) throws GraphQLRequestExecutionException {
24762476
if (logger.isTraceEnabled()) {
2477-
StringBuffer sb = new StringBuffer();
2477+
StringBuilder sb = new StringBuilder();
24782478
sb.append("Executing query 'allFieldCases' with bind variables: ");
24792479
boolean addComma = false;
24802480
for (Object o : paramsAndValues) {
@@ -2747,7 +2747,7 @@ public List<AnyCharacter> unionTestWithBindValues(ObjectResponse objectResponse,
27472747
public List<AnyCharacter> unionTest(ObjectResponse objectResponse, HumanInput human1, HumanInput human2,
27482748
DroidInput droid1, DroidInput droid2, Object... paramsAndValues) throws GraphQLRequestExecutionException {
27492749
if (logger.isTraceEnabled()) {
2750-
StringBuffer sb = new StringBuffer();
2750+
StringBuilder sb = new StringBuilder();
27512751
sb.append("Executing query 'unionTest' with bind variables: ");
27522752
boolean addComma = false;
27532753
for (Object o : paramsAndValues) {
@@ -3004,7 +3004,7 @@ public Character errorWithBindValues(ObjectResponse objectResponse, String error
30043004
public Character error(ObjectResponse objectResponse, String errorLabel, Object... paramsAndValues)
30053005
throws GraphQLRequestExecutionException {
30063006
if (logger.isTraceEnabled()) {
3007-
StringBuffer sb = new StringBuffer();
3007+
StringBuilder sb = new StringBuilder();
30083008
sb.append("Executing query 'error' with bind variables: ");
30093009
boolean addComma = false;
30103010
for (Object o : paramsAndValues) {
@@ -3232,7 +3232,7 @@ public _break aBreakWithBindValues(ObjectResponse objectResponse, Map<String, Ob
32323232
public _break aBreak(ObjectResponse objectResponse, Object... paramsAndValues)
32333233
throws GraphQLRequestExecutionException {
32343234
if (logger.isTraceEnabled()) {
3235-
StringBuffer sb = new StringBuffer();
3235+
StringBuilder sb = new StringBuilder();
32363236
sb.append("Executing query 'aBreak' with bind variables: ");
32373237
boolean addComma = false;
32383238
for (Object o : paramsAndValues) {
@@ -3471,7 +3471,7 @@ public List<String> directiveOnQueryWithBindValues(ObjectResponse objectResponse
34713471
public List<String> directiveOnQuery(ObjectResponse objectResponse, Boolean uppercase, Object... paramsAndValues)
34723472
throws GraphQLRequestExecutionException {
34733473
if (logger.isTraceEnabled()) {
3474-
StringBuffer sb = new StringBuffer();
3474+
StringBuilder sb = new StringBuilder();
34753475
sb.append("Executing query 'directiveOnQuery' with bind variables: ");
34763476
boolean addComma = false;
34773477
for (Object o : paramsAndValues) {
@@ -3706,7 +3706,7 @@ public Character directiveOnFieldWithBindValues(ObjectResponse objectResponse, M
37063706
public Character directiveOnField(ObjectResponse objectResponse, Object... paramsAndValues)
37073707
throws GraphQLRequestExecutionException {
37083708
if (logger.isTraceEnabled()) {
3709-
StringBuffer sb = new StringBuffer();
3709+
StringBuilder sb = new StringBuilder();
37103710
sb.append("Executing query 'directiveOnField' with bind variables: ");
37113711
boolean addComma = false;
37123712
for (Object o : paramsAndValues) {
@@ -3938,7 +3938,7 @@ public List<Character> connectionWithoutParametersWithBindValues(ObjectResponse
39383938
public List<Character> connectionWithoutParameters(ObjectResponse objectResponse, Object... paramsAndValues)
39393939
throws GraphQLRequestExecutionException {
39403940
if (logger.isTraceEnabled()) {
3941-
StringBuffer sb = new StringBuffer();
3941+
StringBuilder sb = new StringBuilder();
39423942
sb.append("Executing query 'connectionWithoutParameters' with bind variables: ");
39433943
boolean addComma = false;
39443944
for (Object o : paramsAndValues) {
@@ -4185,7 +4185,7 @@ public List<Human> connectionOnHumanWithBindValues(ObjectResponse objectResponse
41854185
public List<Human> connectionOnHuman(ObjectResponse objectResponse, String planet, Episode episode,
41864186
Object... paramsAndValues) throws GraphQLRequestExecutionException {
41874187
if (logger.isTraceEnabled()) {
4188-
StringBuffer sb = new StringBuffer();
4188+
StringBuilder sb = new StringBuilder();
41894189
sb.append("Executing query 'connectionOnHuman' with bind variables: ");
41904190
boolean addComma = false;
41914191
for (Object o : paramsAndValues) {
@@ -4431,7 +4431,7 @@ public Date issue53WithBindValues(ObjectResponse objectResponse, Date date, Map<
44314431
public Date issue53(ObjectResponse objectResponse, Date date, Object... paramsAndValues)
44324432
throws GraphQLRequestExecutionException {
44334433
if (logger.isTraceEnabled()) {
4434-
StringBuffer sb = new StringBuffer();
4434+
StringBuilder sb = new StringBuilder();
44354435
sb.append("Executing query 'issue53' with bind variables: ");
44364436
boolean addComma = false;
44374437
for (Object o : paramsAndValues) {
@@ -4670,7 +4670,7 @@ public Double issue82FloatWithBindValues(ObjectResponse objectResponse, Double a
46704670
public Double issue82Float(ObjectResponse objectResponse, Double aFloat, Object... paramsAndValues)
46714671
throws GraphQLRequestExecutionException {
46724672
if (logger.isTraceEnabled()) {
4673-
StringBuffer sb = new StringBuffer();
4673+
StringBuilder sb = new StringBuilder();
46744674
sb.append("Executing query 'issue82Float' with bind variables: ");
46754675
boolean addComma = false;
46764676
for (Object o : paramsAndValues) {
@@ -4907,7 +4907,7 @@ public String issue82IDWithBindValues(ObjectResponse objectResponse, String aID,
49074907
public String issue82ID(ObjectResponse objectResponse, String aID, Object... paramsAndValues)
49084908
throws GraphQLRequestExecutionException {
49094909
if (logger.isTraceEnabled()) {
4910-
StringBuffer sb = new StringBuffer();
4910+
StringBuilder sb = new StringBuilder();
49114911
sb.append("Executing query 'issue82ID' with bind variables: ");
49124912
boolean addComma = false;
49134913
for (Object o : paramsAndValues) {
@@ -5135,7 +5135,7 @@ public MyQueryType relayWithBindValues(ObjectResponse objectResponse, Map<String
51355135
public MyQueryType relay(ObjectResponse objectResponse, Object... paramsAndValues)
51365136
throws GraphQLRequestExecutionException {
51375137
if (logger.isTraceEnabled()) {
5138-
StringBuffer sb = new StringBuffer();
5138+
StringBuilder sb = new StringBuilder();
51395139
sb.append("Executing query 'relay' with bind variables: ");
51405140
boolean addComma = false;
51415141
for (Object o : paramsAndValues) {
@@ -5358,7 +5358,7 @@ public __Schema __schemaWithBindValues(ObjectResponse objectResponse, Map<String
53585358
public __Schema __schema(ObjectResponse objectResponse, Object... paramsAndValues)
53595359
throws GraphQLRequestExecutionException {
53605360
if (logger.isTraceEnabled()) {
5361-
StringBuffer sb = new StringBuffer();
5361+
StringBuilder sb = new StringBuilder();
53625362
sb.append("Executing query '__schema' with bind variables: ");
53635363
boolean addComma = false;
53645364
for (Object o : paramsAndValues) {
@@ -5589,7 +5589,7 @@ public __Type __typeWithBindValues(ObjectResponse objectResponse, String name, M
55895589
public __Type __type(ObjectResponse objectResponse, String name, Object... paramsAndValues)
55905590
throws GraphQLRequestExecutionException {
55915591
if (logger.isTraceEnabled()) {
5592-
StringBuffer sb = new StringBuffer();
5592+
StringBuilder sb = new StringBuilder();
55935593
sb.append("Executing query '__type' with bind variables: ");
55945594
boolean addComma = false;
55955595
for (Object o : paramsAndValues) {
@@ -5814,7 +5814,7 @@ public String __typenameWithBindValues(ObjectResponse objectResponse, Map<String
58145814
public String __typename(ObjectResponse objectResponse, Object... paramsAndValues)
58155815
throws GraphQLRequestExecutionException {
58165816
if (logger.isTraceEnabled()) {
5817-
StringBuffer sb = new StringBuffer();
5817+
StringBuilder sb = new StringBuilder();
58185818
sb.append("Executing query '__typename' with bind variables: ");
58195819
boolean addComma = false;
58205820
for (Object o : paramsAndValues) {

0 commit comments

Comments
 (0)