Skip to content

Commit ee968e1

Browse files
committed
add java doc
1 parent 156d8ad commit ee968e1

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/main/java/graphql/annotations/MethodDataFetcher.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2016 Yurii Rashkovskii
3-
*
3+
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
* <p>
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,10 +32,9 @@ class MethodDataFetcher implements DataFetcher {
3232
private final TypeFunction typeFunction;
3333

3434

35-
36-
public MethodDataFetcher(Method method,TypeFunction typeFunction, ProcessingElementsContainer container) {
35+
public MethodDataFetcher(Method method, TypeFunction typeFunction, ProcessingElementsContainer container) {
3736
this.method = method;
38-
this.typeFunction=typeFunction;
37+
this.typeFunction = typeFunction;
3938
this.container = container;
4039
}
4140

@@ -56,15 +55,15 @@ public Object get(DataFetchingEnvironment environment) {
5655
return null;
5756
}
5857
}
59-
return method.invoke(obj, invocationArgs(environment,container));
58+
return method.invoke(obj, invocationArgs(environment, container));
6059
} catch (IllegalAccessException | InvocationTargetException e) {
6160
throw new RuntimeException(e);
6261
}
6362
}
6463

65-
private Object[] invocationArgs(DataFetchingEnvironment environment,ProcessingElementsContainer container) {
64+
private Object[] invocationArgs(DataFetchingEnvironment environment, ProcessingElementsContainer container) {
6665
List<Object> result = new ArrayList<>();
67-
Map<String,Object> envArgs = environment.getArguments();
66+
Map<String, Object> envArgs = environment.getArguments();
6867
for (Parameter p : method.getParameters()) {
6968
String parameterName;
7069
GraphQLName name = p.getAnnotation(GraphQLName.class);
@@ -80,7 +79,7 @@ private Object[] invocationArgs(DataFetchingEnvironment environment,ProcessingEl
8079
continue;
8180
}
8281

83-
graphql.schema.GraphQLType graphQLType = typeFunction.buildType(true, paramType, p.getAnnotatedType(),container);
82+
graphql.schema.GraphQLType graphQLType = typeFunction.buildType(true, paramType, p.getAnnotatedType(), container);
8483
if (envArgs.containsKey(parameterName)) {
8584
result.add(buildArg(p.getParameterizedType(), graphQLType, envArgs.get(parameterName)));
8685
} else {
@@ -108,15 +107,15 @@ private Object buildArg(Type p, GraphQLType graphQLType, Object arg) {
108107
Map map = (Map) arg;
109108
for (Parameter parameter : parameters) {
110109
String name = toGraphqlName(parameter.getAnnotation(GraphQLName.class) != null ? parameter.getAnnotation(GraphQLName.class).value() : parameter.getName());
111-
objects.add(buildArg(parameter.getParameterizedType(), ((GraphQLInputObjectType)graphQLType).getField(name).getType(),map.get(name)));
110+
objects.add(buildArg(parameter.getParameterizedType(), ((GraphQLInputObjectType) graphQLType).getField(name).getType(), map.get(name)));
112111
}
113112
return constructNewInstance(constructor, objects.toArray(new Object[objects.size()]));
114113
}
115114
}
116115
return null;
117116
} else if (p instanceof ParameterizedType && graphQLType instanceof GraphQLList) {
118117
List<Object> list = new ArrayList<>();
119-
Type subType = ((ParameterizedType)p).getActualTypeArguments()[0];
118+
Type subType = ((ParameterizedType) p).getActualTypeArguments()[0];
120119
GraphQLType wrappedType = ((GraphQLList) graphQLType).getWrappedType();
121120

122121
for (Object item : ((List) arg)) {

src/main/java/graphql/annotations/TypeFunction.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2016 Yurii Rashkovskii
3-
*
3+
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,10 +42,16 @@ default String getTypeName(Class<?> aClass, AnnotatedType annotatedType) {
4242
*/
4343
boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType);
4444

45-
45+
/**
46+
*
47+
* @param aClass The java type to build the type name for
48+
* @param annotatedType The {@link AnnotatedType} of the java type, which may be a {link AnnotatedParameterizedType}
49+
* @param container a class that hold several members that are required in order to build schema
50+
* @return The built
51+
*/
4652

4753
default GraphQLType buildType(Class<?> aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) {
48-
return buildType(false, aClass, annotatedType,container);
54+
return buildType(false, aClass, annotatedType, container);
4955
}
5056

5157
/**

0 commit comments

Comments
 (0)