Package graphql.schema
Class PropertyFetchingImpl
java.lang.Object
graphql.schema.PropertyFetchingImpl
A re-usable class that can fetch from POJOs
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private final class
private static final class
private static class
private static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<PropertyFetchingImpl.CacheKey, Field> private final ConcurrentMap
<PropertyFetchingImpl.CacheKey, PropertyFetchingImpl.CachedLambdaFunction> private static final org.slf4j.Logger
private final Class
<?> private final AtomicBoolean
private final AtomicBoolean
private final AtomicBoolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
private Method
findPubliclyAccessibleMethod
(PropertyFetchingImpl.CacheKey cacheKey, Class<?> rootClass, String methodName, boolean dfeInUse, boolean allowStaticMethods) Invoking public methods on package-protected classes via reflection causes exceptions.private Method
findRecordMethod
(PropertyFetchingImpl.CacheKey cacheKey, Class<?> rootClass, String methodName) private Method
findViaSetAccessible
(PropertyFetchingImpl.CacheKey cacheKey, Class<?> aClass, String methodName, boolean dfeInUse) getPropertyValue
(String propertyName, Object object, GraphQLType graphQLType, boolean dfeInUse, Supplier<Object> singleArgumentValue) private Object
getPropertyViaFieldAccess
(PropertyFetchingImpl.CacheKey cacheKey, Object object, String propertyName) private Object
getPropertyViaGetterMethod
(Object object, String propertyName, GraphQLType graphQLType, PropertyFetchingImpl.MethodFinder methodFinder, Supplier<Object> singleArgumentValue) private Object
getPropertyViaGetterUsingPrefix
(Object object, String propertyName, String prefix, PropertyFetchingImpl.MethodFinder methodFinder, Supplier<Object> singleArgumentValue) private Object
getPropertyViaRecordMethod
(Object object, String propertyName, PropertyFetchingImpl.MethodFinder methodFinder, Supplier<Object> singleArgumentValue) private boolean
hasZeroArgs
(Method mth) private Object
invokeField
(Object object, Field field) private Object
invokeMethod
(Object object, Supplier<Object> singleArgumentValue, Method method, boolean takesSingleArgument) private boolean
isBooleanProperty
(GraphQLType graphQLType) private boolean
private boolean
isSuitablePublicMethod
(Method method, boolean allowStaticMethods) lambdaGetter
(String propertyName, Object object) private PropertyFetchingImpl.CacheKey
mkCacheKey
(Object object, String propertyName) private static Comparator
<? super Method> private void
boolean
setUseLambdaFactory
(boolean flag) boolean
setUseNegativeCache
(boolean flag) boolean
setUseSetAccessible
(boolean flag) private boolean
-
Field Details
-
log
private static final org.slf4j.Logger log -
USE_SET_ACCESSIBLE
-
USE_LAMBDA_FACTORY
-
USE_NEGATIVE_CACHE
-
LAMBDA_CACHE
private final ConcurrentMap<PropertyFetchingImpl.CacheKey,PropertyFetchingImpl.CachedLambdaFunction> LAMBDA_CACHE -
METHOD_CACHE
private final ConcurrentMap<PropertyFetchingImpl.CacheKey,PropertyFetchingImpl.CachedMethod> METHOD_CACHE -
FIELD_CACHE
-
NEGATIVE_CACHE
private final ConcurrentMap<PropertyFetchingImpl.CacheKey,PropertyFetchingImpl.CacheKey> NEGATIVE_CACHE -
singleArgumentType
-
-
Constructor Details
-
PropertyFetchingImpl
-
-
Method Details
-
getPropertyValue
-
lambdaGetter
-
isNegativelyCached
-
putInNegativeCache
-
getPropertyViaRecordMethod
private Object getPropertyViaRecordMethod(Object object, String propertyName, PropertyFetchingImpl.MethodFinder methodFinder, Supplier<Object> singleArgumentValue) throws NoSuchMethodException - Throws:
NoSuchMethodException
-
getPropertyViaGetterMethod
private Object getPropertyViaGetterMethod(Object object, String propertyName, GraphQLType graphQLType, PropertyFetchingImpl.MethodFinder methodFinder, Supplier<Object> singleArgumentValue) throws NoSuchMethodException - Throws:
NoSuchMethodException
-
getPropertyViaGetterUsingPrefix
private Object getPropertyViaGetterUsingPrefix(Object object, String propertyName, String prefix, PropertyFetchingImpl.MethodFinder methodFinder, Supplier<Object> singleArgumentValue) throws NoSuchMethodException - Throws:
NoSuchMethodException
-
findPubliclyAccessibleMethod
private Method findPubliclyAccessibleMethod(PropertyFetchingImpl.CacheKey cacheKey, Class<?> rootClass, String methodName, boolean dfeInUse, boolean allowStaticMethods) throws NoSuchMethodException Invoking public methods on package-protected classes via reflection causes exceptions. This method searches a class's hierarchy for public visibility parent classes with the desired getter. This particular case is required to support AutoValue style data classes, which have abstract public interfaces implemented by package-protected (generated) subclasses.- Throws:
NoSuchMethodException
-
isSuitablePublicMethod
-
findRecordMethod
private Method findRecordMethod(PropertyFetchingImpl.CacheKey cacheKey, Class<?> rootClass, String methodName) throws NoSuchMethodException - Throws:
NoSuchMethodException
-
findViaSetAccessible
private Method findViaSetAccessible(PropertyFetchingImpl.CacheKey cacheKey, Class<?> aClass, String methodName, boolean dfeInUse) throws NoSuchMethodException - Throws:
NoSuchMethodException
-
getPropertyViaFieldAccess
private Object getPropertyViaFieldAccess(PropertyFetchingImpl.CacheKey cacheKey, Object object, String propertyName) throws PropertyFetchingImpl.FastNoSuchMethodException -
invokeMethod
-
invokeField
-
isBooleanProperty
-
clearReflectionCache
public void clearReflectionCache() -
setUseSetAccessible
public boolean setUseSetAccessible(boolean flag) -
setUseLambdaFactory
public boolean setUseLambdaFactory(boolean flag) -
setUseNegativeCache
public boolean setUseNegativeCache(boolean flag) -
mkCacheKey
-
hasZeroArgs
-
takesSingleArgumentTypeAsOnlyArgument
-
mostMethodArgsFirst
-