@SuppressWarnings("unchecked")
    public static <R> QueryResult<R> handleBasicQueries(
        final Query<R> query,
        final PositionBound positionBound,
        final QueryConfig config,
        final StateStore store,
        final Position position,
        final StateStoreContext context
    ) {

        final long start = config.isCollectExecutionInfo() ? System.nanoTime() : -1L;
        final QueryResult<R> result;

        final QueryHandler handler = QUERY_HANDLER_MAP.get(query.getClass());
        synchronized (position) {
            if (handler == null) {
                result = QueryResult.forUnknownQueryType(query, store);
            } else if (context == null || !isPermitted(position, positionBound, context.taskId().partition())) {
                result = QueryResult.notUpToBound(
                    position,
                    positionBound,
                    context == null ? null : context.taskId().partition()
                );
            } else {
                result = (QueryResult<R>) handler.apply(
                    query,
                    positionBound,
                    config,
                    store
                );
            }
            if (config.isCollectExecutionInfo()) {
                result.addExecutionInfo(
                    "Handled in " + store.getClass() + " in " + (System.nanoTime() - start) + "ns"
                );
            }
            result.setPosition(position.copy());
        }
        return result;
    }
a utility interface to facilitate stores' query dispatch logic,
allowing them to generically store query execution logic as the values
in a map.
streams/src/main/java/org/apache/kafka/streams/state/internals/StoreQueryUtils.java