Skip to content

Commit eba26a3

Browse files
authored
Code cleanup (#670)
1 parent 6e47963 commit eba26a3

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

docs/client-side-cases-by-proxy.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
4242
/**
4343
* this is graphql request need that what response fields.
4444
*/
45-
private GraphQLResponseProjection projection;
45+
private final GraphQLResponseProjection projection;
4646

4747
/**
4848
* this graphql request that need request params. (if have)
4949
*/
50-
private GraphQLOperationRequest request;
50+
private final GraphQLOperationRequest request;
5151

5252
/**
5353
* should limit max depth when invoke method on projection.
5454
*/
55-
private int maxDepth;
55+
private final int maxDepth;
5656

5757
DynamicProxy(GraphQLResponseProjection projection, GraphQLOperationRequest request, int maxDepth) {
5858
this.projection = projection;
@@ -79,7 +79,7 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
7979

8080
/**
8181
* proxy invoke
82-
*
82+
*
8383
* <p>when handle projection, we use reflect to invoke method directly
8484
* but when handle request(need set parameters), we use reflect to get field which is a internal implementation of set method
8585
*
@@ -166,10 +166,10 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
166166
//if this method have no parameter, then do not need invoke on request instance
167167
//other wise, we need append parameters to request field which use hashmap store params
168168
if (!parameters.isEmpty()) {
169-
for (Parameter parameter : parameters) {
170-
Object argsCopy = args[i++];
171-
request.getInput().put(parameter.getName(), argsCopy);
172-
}
169+
for (Parameter parameter : parameters) {
170+
Object argsCopy = args[i++];
171+
request.getInput().put(parameter.getName(), argsCopy);
172+
}
173173
}
174174
try {
175175
field = projection.getClass().getSuperclass().getDeclaredField("fields");
@@ -191,7 +191,7 @@ final public class DynamicProxy implements InvocationHandler, ExecutionGraphql {
191191
}
192192

193193
return executeByHttp(entityClazzName, request, projection);// request and projection for creating GraphQLRequest, entityClazzName for deserialize
194-
}
194+
}
195195
}
196196
```
197197

plugins/gradle/graphql-java-codegen-gradle-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/gradle/GraphQLCodegenGradleTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
8787
private Set<String> fieldsWithResolvers = new HashSet<>();
8888
private Set<String> fieldsWithoutResolvers = new HashSet<>();
8989
private Set<String> typesAsInterfaces = new HashSet<>();
90-
private RelayConfig relayConfig = new RelayConfig();
90+
private final RelayConfig relayConfig = new RelayConfig();
9191

9292

9393
private Boolean generateClient;

src/main/java/com/kobylynskyi/graphql/codegen/FreeMarkerTemplateType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ enum FreeMarkerTemplateType {
1111
OPERATIONS,
1212
PARAMETRIZED_INPUT,
1313
RESPONSE_PROJECTION,
14-
JACKSON_TYPE_ID_RESOLVER;
14+
JACKSON_TYPE_ID_RESOLVER
1515

1616
}

src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ default NamedDefinition getLanguageType(MappingContext mappingContext, String gr
225225
Set<String> serializeFieldsUsingObjectMapper = mappingContext.getUseObjectMapperForRequestSerialization();
226226
String langTypeName;
227227
boolean primitiveCanBeUsed = !collection;
228-
boolean serializeUsingObjectMapper = false;
229228
if (name != null && parentTypeName != null && customTypesMapping.containsKey(parentTypeName + "." + name)) {
230229
langTypeName = customTypesMapping.get(parentTypeName + "." + name);
231230
primitiveCanBeUsed = false;
@@ -236,11 +235,9 @@ default NamedDefinition getLanguageType(MappingContext mappingContext, String gr
236235
} else {
237236
langTypeName = DataModelMapper.getModelClassNameWithPrefixAndSuffix(mappingContext, graphQLType);
238237
}
239-
if (serializeFieldsUsingObjectMapper.contains(graphQLType) ||
240-
(name != null && parentTypeName != null &&
241-
serializeFieldsUsingObjectMapper.contains(parentTypeName + "." + name))) {
242-
serializeUsingObjectMapper = true;
243-
}
238+
boolean serializeUsingObjectMapper =
239+
serializeFieldsUsingObjectMapper.contains(graphQLType) ||
240+
serializeFieldsUsingObjectMapper.contains(parentTypeName + "." + name);
244241

245242
return new NamedDefinition(langTypeName, graphQLType, mappingContext.getInterfacesName().contains(graphQLType),
246243
mandatory, primitiveCanBeUsed, serializeUsingObjectMapper);
@@ -370,7 +367,7 @@ default List<String> getJacksonTypeIdAnnotations(MappingContext mappingContext,
370367
*/
371368
String getJacksonResolverTypeIdAnnotation(String modelPackageName);
372369

373-
default List<String> getAdditionalAnnotations(MappingContext mappingContext, String typeName) {
370+
default List<String> getAdditionalAnnotations(MappingContext mappingContext, String typeName) {
374371
return new ArrayList<>();
375372
}
376373

src/main/java/com/kobylynskyi/graphql/codegen/model/ApiNamePrefixStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public enum ApiNamePrefixStrategy {
2424
/**
2525
* Will take only the value of apiNamePrefix config option.
2626
*/
27-
CONSTANT;
27+
CONSTANT
2828

2929
}

0 commit comments

Comments
 (0)