@@ -38,13 +38,13 @@ public PropertyFetchingImpl(Class<?> singleArgumentType) {
3838 this .singleArgumentType = singleArgumentType ;
3939 }
4040
41- private static class CachedMethod {
41+ private class CachedMethod {
4242 Method method ;
43- boolean takesDataFetcherEnvironmentAsOnlyArgument ;
43+ boolean takesSingleArgumentTypeAsOnlyArgument ;
4444
4545 CachedMethod (Method method ) {
4646 this .method = method ;
47- this .takesDataFetcherEnvironmentAsOnlyArgument = takesDataFetcherEnvironmentAsOnlyArgument (method );
47+ this .takesSingleArgumentTypeAsOnlyArgument = takesSingleArgumentTypeAsOnlyArgument (method );
4848 }
4949
5050 }
@@ -53,7 +53,7 @@ public Object getPropertyValue(String propertyName, Object object, GraphQLType g
5353 return getPropertyValue (propertyName , object , graphQLType , null );
5454 }
5555
56- public Object getPropertyValue (String propertyName , Object object , GraphQLType graphQLType , DataFetchingEnvironment environment ) {
56+ public Object getPropertyValue (String propertyName , Object object , GraphQLType graphQLType , Object singleArgumentValue ) {
5757 if (object instanceof Map ) {
5858 return ((Map <?, ?>) object ).get (propertyName );
5959 }
@@ -64,7 +64,7 @@ public Object getPropertyValue(String propertyName, Object object, GraphQLType g
6464 CachedMethod cachedMethod = METHOD_CACHE .get (cacheKey );
6565 if (cachedMethod != null ) {
6666 try {
67- return invokeMethod (object , environment , cachedMethod .method , cachedMethod .takesDataFetcherEnvironmentAsOnlyArgument );
67+ return invokeMethod (object , singleArgumentValue , cachedMethod .method , cachedMethod .takesSingleArgumentTypeAsOnlyArgument );
6868 } catch (NoSuchMethodException ignored ) {
6969 assertShouldNeverHappen ("A method cached as '%s' is no longer available??" , cacheKey );
7070 }
@@ -90,14 +90,14 @@ public Object getPropertyValue(String propertyName, Object object, GraphQLType g
9090 // ok we haven't cached it and we haven't negatively cached it so we have to find the POJO method which is the most
9191 // expensive operation here
9292 //
93- boolean dfeInUse = environment != null ;
93+ boolean dfeInUse = singleArgumentValue != null ;
9494 try {
9595 MethodFinder methodFinder = (root , methodName ) -> findPubliclyAccessibleMethod (cacheKey , root , methodName , dfeInUse );
96- return getPropertyViaGetterMethod (object , propertyName , graphQLType , methodFinder , environment );
96+ return getPropertyViaGetterMethod (object , propertyName , graphQLType , methodFinder , singleArgumentValue );
9797 } catch (NoSuchMethodException ignored ) {
9898 try {
9999 MethodFinder methodFinder = (aClass , methodName ) -> findViaSetAccessible (cacheKey , aClass , methodName , dfeInUse );
100- return getPropertyViaGetterMethod (object , propertyName , graphQLType , methodFinder , environment );
100+ return getPropertyViaGetterMethod (object , propertyName , graphQLType , methodFinder , singleArgumentValue );
101101 } catch (NoSuchMethodException ignored2 ) {
102102 try {
103103 return getPropertyViaFieldAccess (cacheKey , object , propertyName );
@@ -127,22 +127,22 @@ private interface MethodFinder {
127127 Method apply (Class <?> aClass , String s ) throws NoSuchMethodException ;
128128 }
129129
130- private Object getPropertyViaGetterMethod (Object object , String propertyName , GraphQLType graphQLType , MethodFinder methodFinder , DataFetchingEnvironment environment ) throws NoSuchMethodException {
130+ private Object getPropertyViaGetterMethod (Object object , String propertyName , GraphQLType graphQLType , MethodFinder methodFinder , Object singleArgumentValue ) throws NoSuchMethodException {
131131 if (isBooleanProperty (graphQLType )) {
132132 try {
133- return getPropertyViaGetterUsingPrefix (object , propertyName , "is" , methodFinder , environment );
133+ return getPropertyViaGetterUsingPrefix (object , propertyName , "is" , methodFinder , singleArgumentValue );
134134 } catch (NoSuchMethodException e ) {
135- return getPropertyViaGetterUsingPrefix (object , propertyName , "get" , methodFinder , environment );
135+ return getPropertyViaGetterUsingPrefix (object , propertyName , "get" , methodFinder , singleArgumentValue );
136136 }
137137 } else {
138- return getPropertyViaGetterUsingPrefix (object , propertyName , "get" , methodFinder , environment );
138+ return getPropertyViaGetterUsingPrefix (object , propertyName , "get" , methodFinder , singleArgumentValue );
139139 }
140140 }
141141
142- private Object getPropertyViaGetterUsingPrefix (Object object , String propertyName , String prefix , MethodFinder methodFinder , DataFetchingEnvironment environment ) throws NoSuchMethodException {
142+ private Object getPropertyViaGetterUsingPrefix (Object object , String propertyName , String prefix , MethodFinder methodFinder , Object singleArgumentValue ) throws NoSuchMethodException {
143143 String getterName = prefix + propertyName .substring (0 , 1 ).toUpperCase () + propertyName .substring (1 );
144144 Method method = methodFinder .apply (object .getClass (), getterName );
145- return invokeMethod (object , environment , method , takesDataFetcherEnvironmentAsOnlyArgument (method ));
145+ return invokeMethod (object , singleArgumentValue , method , takesSingleArgumentTypeAsOnlyArgument (method ));
146146 }
147147
148148 /**
@@ -190,7 +190,7 @@ private Method findViaSetAccessible(String cacheKey, Class<?> aClass, String met
190190 while (currentClass != null ) {
191191 Predicate <Method > whichMethods = mth -> {
192192 if (dfeInUse ) {
193- return hasZeroArgs (mth ) || takesDataFetcherEnvironmentAsOnlyArgument (mth );
193+ return hasZeroArgs (mth ) || takesSingleArgumentTypeAsOnlyArgument (mth );
194194 }
195195 return hasZeroArgs (mth );
196196 };
@@ -240,13 +240,13 @@ private Object getPropertyViaFieldAccess(String cacheKey, Object object, String
240240 }
241241 }
242242
243- private Object invokeMethod (Object object , DataFetchingEnvironment environment , Method method , boolean takesDataFetcherEnvironmentAsOnlyArgument ) throws FastNoSuchMethodException {
243+ private Object invokeMethod (Object object , Object singleArgumentValue , Method method , boolean takesSingleArgument ) throws FastNoSuchMethodException {
244244 try {
245- if (takesDataFetcherEnvironmentAsOnlyArgument ) {
246- if (environment == null ) {
245+ if (takesSingleArgument ) {
246+ if (singleArgumentValue == null ) {
247247 throw new FastNoSuchMethodException (method .getName ());
248248 }
249- return method .invoke (object , environment );
249+ return method .invoke (object , singleArgumentValue );
250250 } else {
251251 return method .invoke (object );
252252 }
@@ -303,9 +303,9 @@ private boolean hasZeroArgs(Method mth) {
303303 return mth .getParameterCount () == 0 ;
304304 }
305305
306- private static boolean takesDataFetcherEnvironmentAsOnlyArgument (Method mth ) {
306+ private boolean takesSingleArgumentTypeAsOnlyArgument (Method mth ) {
307307 return mth .getParameterCount () == 1 &&
308- mth .getParameterTypes ()[0 ].equals (DataFetchingEnvironment . class );
308+ mth .getParameterTypes ()[0 ].equals (singleArgumentType );
309309 }
310310
311311 private static Comparator <? super Method > mostMethodArgsFirst () {
0 commit comments