Class PropertyFetchingImpl


  • public class PropertyFetchingImpl
    extends java.lang.Object
    A re-usable class that can fetch from POJOs
    • Constructor Detail

      • PropertyFetchingImpl

        public PropertyFetchingImpl​(java.lang.Class<?> singleArgumentType)
    • Method Detail

      • getPropertyValue

        public java.lang.Object getPropertyValue​(java.lang.String propertyName,
                                                 java.lang.Object object,
                                                 GraphQLType graphQLType,
                                                 boolean dfeInUse,
                                                 java.util.function.Supplier<java.lang.Object> singleArgumentValue)
      • lambdaGetter

        private java.util.Optional<java.util.function.Function<java.lang.Object,​java.lang.Object>> lambdaGetter​(java.lang.String propertyName,
                                                                                                                      java.lang.Object object)
      • getPropertyViaRecordMethod

        private java.lang.Object getPropertyViaRecordMethod​(java.lang.Object object,
                                                            java.lang.String propertyName,
                                                            PropertyFetchingImpl.MethodFinder methodFinder,
                                                            java.util.function.Supplier<java.lang.Object> singleArgumentValue)
                                                     throws java.lang.NoSuchMethodException
        Throws:
        java.lang.NoSuchMethodException
      • getPropertyViaGetterMethod

        private java.lang.Object getPropertyViaGetterMethod​(java.lang.Object object,
                                                            java.lang.String propertyName,
                                                            GraphQLType graphQLType,
                                                            PropertyFetchingImpl.MethodFinder methodFinder,
                                                            java.util.function.Supplier<java.lang.Object> singleArgumentValue)
                                                     throws java.lang.NoSuchMethodException
        Throws:
        java.lang.NoSuchMethodException
      • getPropertyViaGetterUsingPrefix

        private java.lang.Object getPropertyViaGetterUsingPrefix​(java.lang.Object object,
                                                                 java.lang.String propertyName,
                                                                 java.lang.String prefix,
                                                                 PropertyFetchingImpl.MethodFinder methodFinder,
                                                                 java.util.function.Supplier<java.lang.Object> singleArgumentValue)
                                                          throws java.lang.NoSuchMethodException
        Throws:
        java.lang.NoSuchMethodException
      • findPubliclyAccessibleMethod

        private java.lang.reflect.Method findPubliclyAccessibleMethod​(PropertyFetchingImpl.CacheKey cacheKey,
                                                                      java.lang.Class<?> rootClass,
                                                                      java.lang.String methodName,
                                                                      boolean dfeInUse,
                                                                      boolean allowStaticMethods)
                                                               throws java.lang.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:
        java.lang.NoSuchMethodException
      • isSuitablePublicMethod

        private boolean isSuitablePublicMethod​(java.lang.reflect.Method method,
                                               boolean allowStaticMethods)
      • findRecordMethod

        private java.lang.reflect.Method findRecordMethod​(PropertyFetchingImpl.CacheKey cacheKey,
                                                          java.lang.Class<?> rootClass,
                                                          java.lang.String methodName)
                                                   throws java.lang.NoSuchMethodException
        Throws:
        java.lang.NoSuchMethodException
      • findViaSetAccessible

        private java.lang.reflect.Method findViaSetAccessible​(PropertyFetchingImpl.CacheKey cacheKey,
                                                              java.lang.Class<?> aClass,
                                                              java.lang.String methodName,
                                                              boolean dfeInUse)
                                                       throws java.lang.NoSuchMethodException
        Throws:
        java.lang.NoSuchMethodException
      • invokeField

        private java.lang.Object invokeField​(java.lang.Object object,
                                             java.lang.reflect.Field field)
      • isBooleanProperty

        private boolean isBooleanProperty​(GraphQLType graphQLType)
      • clearReflectionCache

        public void clearReflectionCache()
      • setUseSetAccessible

        public boolean setUseSetAccessible​(boolean flag)
      • setUseLambdaFactory

        public boolean setUseLambdaFactory​(boolean flag)
      • setUseNegativeCache

        public boolean setUseNegativeCache​(boolean flag)
      • hasZeroArgs

        private boolean hasZeroArgs​(java.lang.reflect.Method mth)
      • takesSingleArgumentTypeAsOnlyArgument

        private boolean takesSingleArgumentTypeAsOnlyArgument​(java.lang.reflect.Method mth)
      • mostMethodArgsFirst

        private static java.util.Comparator<? super java.lang.reflect.Method> mostMethodArgsFirst()