All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.schema.PropertyDataFetcherHelper Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
package graphql.schema;

import graphql.Internal;
import graphql.VisibleForTesting;

import java.util.function.Supplier;

/**
 * This class is the guts of a property data fetcher and also used in AST code to turn
 * in memory java objects into AST elements
 */
@Internal
public class PropertyDataFetcherHelper {

    private static final PropertyFetchingImpl impl = new PropertyFetchingImpl(DataFetchingEnvironment.class);
    private static final Supplier ALWAYS_NULL = () -> null;

    public static Object getPropertyValue(String propertyName, Object object, GraphQLType graphQLType) {
        return impl.getPropertyValue(propertyName, object, graphQLType, false, ALWAYS_NULL);
    }

    public static Object getPropertyValue(String propertyName, Object object, GraphQLType graphQLType, Supplier environment) {
        return impl.getPropertyValue(propertyName, object, graphQLType, true, environment);
    }

    public static void clearReflectionCache() {
        impl.clearReflectionCache();
    }

    public static boolean setUseSetAccessible(boolean flag) {
        return impl.setUseSetAccessible(flag);
    }

    @VisibleForTesting
    public static boolean setUseLambdaFactory(boolean flag) {
        return impl.setUseLambdaFactory(flag);
    }

    public static boolean setUseNegativeCache(boolean flag) {
        return impl.setUseNegativeCache(flag);
    }
}