// Code generated by ent, DO NOT EDIT.

package intercept

import (
	"context"
	"fmt"

	"entgo.io/ent/dialect/sql"
	"github.com/buildbarn/bb-portal/ent/gen/ent"
	"github.com/buildbarn/bb-portal/ent/gen/ent/actioncachestatistics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/actiondata"
	"github.com/buildbarn/bb-portal/ent/gen/ent/actionsummary"
	"github.com/buildbarn/bb-portal/ent/gen/ent/artifactmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/bazelinvocation"
	"github.com/buildbarn/bb-portal/ent/gen/ent/bazelinvocationproblem"
	"github.com/buildbarn/bb-portal/ent/gen/ent/blob"
	"github.com/buildbarn/bb-portal/ent/gen/ent/build"
	"github.com/buildbarn/bb-portal/ent/gen/ent/buildgraphmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/cumulativemetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/dynamicexecutionmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/evaluationstat"
	"github.com/buildbarn/bb-portal/ent/gen/ent/eventfile"
	"github.com/buildbarn/bb-portal/ent/gen/ent/exectioninfo"
	"github.com/buildbarn/bb-portal/ent/gen/ent/filesmetric"
	"github.com/buildbarn/bb-portal/ent/gen/ent/garbagemetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/memorymetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/metrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/missdetail"
	"github.com/buildbarn/bb-portal/ent/gen/ent/namedsetoffiles"
	"github.com/buildbarn/bb-portal/ent/gen/ent/networkmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/outputgroup"
	"github.com/buildbarn/bb-portal/ent/gen/ent/packageloadmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/packagemetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/predicate"
	"github.com/buildbarn/bb-portal/ent/gen/ent/racestatistics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/resourceusage"
	"github.com/buildbarn/bb-portal/ent/gen/ent/runnercount"
	"github.com/buildbarn/bb-portal/ent/gen/ent/sourcecontrol"
	"github.com/buildbarn/bb-portal/ent/gen/ent/systemnetworkstats"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetcomplete"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetconfigured"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetmetrics"
	"github.com/buildbarn/bb-portal/ent/gen/ent/targetpair"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testcollection"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testfile"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testresultbes"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testsummary"
	"github.com/buildbarn/bb-portal/ent/gen/ent/timingbreakdown"
	"github.com/buildbarn/bb-portal/ent/gen/ent/timingchild"
	"github.com/buildbarn/bb-portal/ent/gen/ent/timingmetrics"
)

// The Query interface represents an operation that queries a graph.
// By using this interface, users can write generic code that manipulates
// query builders of different types.
type Query interface {
	// Type returns the string representation of the query type.
	Type() string
	// Limit the number of records to be returned by this query.
	Limit(int)
	// Offset to start from.
	Offset(int)
	// Unique configures the query builder to filter duplicate records.
	Unique(bool)
	// Order specifies how the records should be ordered.
	Order(...func(*sql.Selector))
	// WhereP appends storage-level predicates to the query builder. Using this method, users
	// can use type-assertion to append predicates that do not depend on any generated package.
	WhereP(...func(*sql.Selector))
}

// The Func type is an adapter that allows ordinary functions to be used as interceptors.
// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
type Func func(context.Context, Query) error

// Intercept calls f(ctx, q) and then applied the next Querier.
func (f Func) Intercept(next ent.Querier) ent.Querier {
	return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) {
		query, err := NewQuery(q)
		if err != nil {
			return nil, err
		}
		if err := f(ctx, query); err != nil {
			return nil, err
		}
		return next.Query(ctx, q)
	})
}

// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
type TraverseFunc func(context.Context, Query) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
	query, err := NewQuery(q)
	if err != nil {
		return err
	}
	return f(ctx, query)
}

// The ActionCacheStatisticsFunc type is an adapter to allow the use of ordinary function as a Querier.
type ActionCacheStatisticsFunc func(context.Context, *ent.ActionCacheStatisticsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f ActionCacheStatisticsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.ActionCacheStatisticsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.ActionCacheStatisticsQuery", q)
}

// The TraverseActionCacheStatistics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseActionCacheStatistics func(context.Context, *ent.ActionCacheStatisticsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseActionCacheStatistics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseActionCacheStatistics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.ActionCacheStatisticsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.ActionCacheStatisticsQuery", q)
}

// The ActionDataFunc type is an adapter to allow the use of ordinary function as a Querier.
type ActionDataFunc func(context.Context, *ent.ActionDataQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f ActionDataFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.ActionDataQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.ActionDataQuery", q)
}

// The TraverseActionData type is an adapter to allow the use of ordinary function as Traverser.
type TraverseActionData func(context.Context, *ent.ActionDataQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseActionData) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseActionData) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.ActionDataQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.ActionDataQuery", q)
}

// The ActionSummaryFunc type is an adapter to allow the use of ordinary function as a Querier.
type ActionSummaryFunc func(context.Context, *ent.ActionSummaryQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f ActionSummaryFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.ActionSummaryQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.ActionSummaryQuery", q)
}

// The TraverseActionSummary type is an adapter to allow the use of ordinary function as Traverser.
type TraverseActionSummary func(context.Context, *ent.ActionSummaryQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseActionSummary) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseActionSummary) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.ActionSummaryQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.ActionSummaryQuery", q)
}

// The ArtifactMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type ArtifactMetricsFunc func(context.Context, *ent.ArtifactMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f ArtifactMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.ArtifactMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.ArtifactMetricsQuery", q)
}

// The TraverseArtifactMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseArtifactMetrics func(context.Context, *ent.ArtifactMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseArtifactMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseArtifactMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.ArtifactMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.ArtifactMetricsQuery", q)
}

// The BazelInvocationFunc type is an adapter to allow the use of ordinary function as a Querier.
type BazelInvocationFunc func(context.Context, *ent.BazelInvocationQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f BazelInvocationFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.BazelInvocationQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.BazelInvocationQuery", q)
}

// The TraverseBazelInvocation type is an adapter to allow the use of ordinary function as Traverser.
type TraverseBazelInvocation func(context.Context, *ent.BazelInvocationQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseBazelInvocation) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseBazelInvocation) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.BazelInvocationQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.BazelInvocationQuery", q)
}

// The BazelInvocationProblemFunc type is an adapter to allow the use of ordinary function as a Querier.
type BazelInvocationProblemFunc func(context.Context, *ent.BazelInvocationProblemQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f BazelInvocationProblemFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.BazelInvocationProblemQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.BazelInvocationProblemQuery", q)
}

// The TraverseBazelInvocationProblem type is an adapter to allow the use of ordinary function as Traverser.
type TraverseBazelInvocationProblem func(context.Context, *ent.BazelInvocationProblemQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseBazelInvocationProblem) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseBazelInvocationProblem) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.BazelInvocationProblemQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.BazelInvocationProblemQuery", q)
}

// The BlobFunc type is an adapter to allow the use of ordinary function as a Querier.
type BlobFunc func(context.Context, *ent.BlobQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f BlobFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.BlobQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.BlobQuery", q)
}

// The TraverseBlob type is an adapter to allow the use of ordinary function as Traverser.
type TraverseBlob func(context.Context, *ent.BlobQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseBlob) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseBlob) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.BlobQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.BlobQuery", q)
}

// The BuildFunc type is an adapter to allow the use of ordinary function as a Querier.
type BuildFunc func(context.Context, *ent.BuildQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f BuildFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.BuildQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.BuildQuery", q)
}

// The TraverseBuild type is an adapter to allow the use of ordinary function as Traverser.
type TraverseBuild func(context.Context, *ent.BuildQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseBuild) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseBuild) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.BuildQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.BuildQuery", q)
}

// The BuildGraphMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type BuildGraphMetricsFunc func(context.Context, *ent.BuildGraphMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f BuildGraphMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.BuildGraphMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.BuildGraphMetricsQuery", q)
}

// The TraverseBuildGraphMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseBuildGraphMetrics func(context.Context, *ent.BuildGraphMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseBuildGraphMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseBuildGraphMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.BuildGraphMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.BuildGraphMetricsQuery", q)
}

// The CumulativeMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type CumulativeMetricsFunc func(context.Context, *ent.CumulativeMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f CumulativeMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.CumulativeMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.CumulativeMetricsQuery", q)
}

// The TraverseCumulativeMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseCumulativeMetrics func(context.Context, *ent.CumulativeMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseCumulativeMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseCumulativeMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.CumulativeMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.CumulativeMetricsQuery", q)
}

// The DynamicExecutionMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type DynamicExecutionMetricsFunc func(context.Context, *ent.DynamicExecutionMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f DynamicExecutionMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.DynamicExecutionMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.DynamicExecutionMetricsQuery", q)
}

// The TraverseDynamicExecutionMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseDynamicExecutionMetrics func(context.Context, *ent.DynamicExecutionMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseDynamicExecutionMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseDynamicExecutionMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.DynamicExecutionMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.DynamicExecutionMetricsQuery", q)
}

// The EvaluationStatFunc type is an adapter to allow the use of ordinary function as a Querier.
type EvaluationStatFunc func(context.Context, *ent.EvaluationStatQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f EvaluationStatFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.EvaluationStatQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.EvaluationStatQuery", q)
}

// The TraverseEvaluationStat type is an adapter to allow the use of ordinary function as Traverser.
type TraverseEvaluationStat func(context.Context, *ent.EvaluationStatQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseEvaluationStat) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseEvaluationStat) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.EvaluationStatQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.EvaluationStatQuery", q)
}

// The EventFileFunc type is an adapter to allow the use of ordinary function as a Querier.
type EventFileFunc func(context.Context, *ent.EventFileQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f EventFileFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.EventFileQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.EventFileQuery", q)
}

// The TraverseEventFile type is an adapter to allow the use of ordinary function as Traverser.
type TraverseEventFile func(context.Context, *ent.EventFileQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseEventFile) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseEventFile) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.EventFileQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.EventFileQuery", q)
}

// The ExectionInfoFunc type is an adapter to allow the use of ordinary function as a Querier.
type ExectionInfoFunc func(context.Context, *ent.ExectionInfoQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f ExectionInfoFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.ExectionInfoQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.ExectionInfoQuery", q)
}

// The TraverseExectionInfo type is an adapter to allow the use of ordinary function as Traverser.
type TraverseExectionInfo func(context.Context, *ent.ExectionInfoQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseExectionInfo) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseExectionInfo) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.ExectionInfoQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.ExectionInfoQuery", q)
}

// The FilesMetricFunc type is an adapter to allow the use of ordinary function as a Querier.
type FilesMetricFunc func(context.Context, *ent.FilesMetricQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f FilesMetricFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.FilesMetricQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.FilesMetricQuery", q)
}

// The TraverseFilesMetric type is an adapter to allow the use of ordinary function as Traverser.
type TraverseFilesMetric func(context.Context, *ent.FilesMetricQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseFilesMetric) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseFilesMetric) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.FilesMetricQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.FilesMetricQuery", q)
}

// The GarbageMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type GarbageMetricsFunc func(context.Context, *ent.GarbageMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f GarbageMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.GarbageMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.GarbageMetricsQuery", q)
}

// The TraverseGarbageMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseGarbageMetrics func(context.Context, *ent.GarbageMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseGarbageMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseGarbageMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.GarbageMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.GarbageMetricsQuery", q)
}

// The MemoryMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type MemoryMetricsFunc func(context.Context, *ent.MemoryMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f MemoryMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.MemoryMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.MemoryMetricsQuery", q)
}

// The TraverseMemoryMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseMemoryMetrics func(context.Context, *ent.MemoryMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseMemoryMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseMemoryMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.MemoryMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.MemoryMetricsQuery", q)
}

// The MetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type MetricsFunc func(context.Context, *ent.MetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f MetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.MetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.MetricsQuery", q)
}

// The TraverseMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseMetrics func(context.Context, *ent.MetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.MetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.MetricsQuery", q)
}

// The MissDetailFunc type is an adapter to allow the use of ordinary function as a Querier.
type MissDetailFunc func(context.Context, *ent.MissDetailQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f MissDetailFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.MissDetailQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.MissDetailQuery", q)
}

// The TraverseMissDetail type is an adapter to allow the use of ordinary function as Traverser.
type TraverseMissDetail func(context.Context, *ent.MissDetailQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseMissDetail) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseMissDetail) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.MissDetailQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.MissDetailQuery", q)
}

// The NamedSetOfFilesFunc type is an adapter to allow the use of ordinary function as a Querier.
type NamedSetOfFilesFunc func(context.Context, *ent.NamedSetOfFilesQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f NamedSetOfFilesFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.NamedSetOfFilesQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.NamedSetOfFilesQuery", q)
}

// The TraverseNamedSetOfFiles type is an adapter to allow the use of ordinary function as Traverser.
type TraverseNamedSetOfFiles func(context.Context, *ent.NamedSetOfFilesQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseNamedSetOfFiles) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseNamedSetOfFiles) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.NamedSetOfFilesQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.NamedSetOfFilesQuery", q)
}

// The NetworkMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type NetworkMetricsFunc func(context.Context, *ent.NetworkMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f NetworkMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.NetworkMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.NetworkMetricsQuery", q)
}

// The TraverseNetworkMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseNetworkMetrics func(context.Context, *ent.NetworkMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseNetworkMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseNetworkMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.NetworkMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.NetworkMetricsQuery", q)
}

// The OutputGroupFunc type is an adapter to allow the use of ordinary function as a Querier.
type OutputGroupFunc func(context.Context, *ent.OutputGroupQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f OutputGroupFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.OutputGroupQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.OutputGroupQuery", q)
}

// The TraverseOutputGroup type is an adapter to allow the use of ordinary function as Traverser.
type TraverseOutputGroup func(context.Context, *ent.OutputGroupQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseOutputGroup) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseOutputGroup) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.OutputGroupQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.OutputGroupQuery", q)
}

// The PackageLoadMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type PackageLoadMetricsFunc func(context.Context, *ent.PackageLoadMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f PackageLoadMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.PackageLoadMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.PackageLoadMetricsQuery", q)
}

// The TraversePackageLoadMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraversePackageLoadMetrics func(context.Context, *ent.PackageLoadMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePackageLoadMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraversePackageLoadMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.PackageLoadMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.PackageLoadMetricsQuery", q)
}

// The PackageMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type PackageMetricsFunc func(context.Context, *ent.PackageMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f PackageMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.PackageMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.PackageMetricsQuery", q)
}

// The TraversePackageMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraversePackageMetrics func(context.Context, *ent.PackageMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePackageMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraversePackageMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.PackageMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.PackageMetricsQuery", q)
}

// The RaceStatisticsFunc type is an adapter to allow the use of ordinary function as a Querier.
type RaceStatisticsFunc func(context.Context, *ent.RaceStatisticsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f RaceStatisticsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.RaceStatisticsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.RaceStatisticsQuery", q)
}

// The TraverseRaceStatistics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseRaceStatistics func(context.Context, *ent.RaceStatisticsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseRaceStatistics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseRaceStatistics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.RaceStatisticsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.RaceStatisticsQuery", q)
}

// The ResourceUsageFunc type is an adapter to allow the use of ordinary function as a Querier.
type ResourceUsageFunc func(context.Context, *ent.ResourceUsageQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f ResourceUsageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.ResourceUsageQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.ResourceUsageQuery", q)
}

// The TraverseResourceUsage type is an adapter to allow the use of ordinary function as Traverser.
type TraverseResourceUsage func(context.Context, *ent.ResourceUsageQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseResourceUsage) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseResourceUsage) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.ResourceUsageQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.ResourceUsageQuery", q)
}

// The RunnerCountFunc type is an adapter to allow the use of ordinary function as a Querier.
type RunnerCountFunc func(context.Context, *ent.RunnerCountQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f RunnerCountFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.RunnerCountQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.RunnerCountQuery", q)
}

// The TraverseRunnerCount type is an adapter to allow the use of ordinary function as Traverser.
type TraverseRunnerCount func(context.Context, *ent.RunnerCountQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseRunnerCount) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseRunnerCount) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.RunnerCountQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.RunnerCountQuery", q)
}

// The SourceControlFunc type is an adapter to allow the use of ordinary function as a Querier.
type SourceControlFunc func(context.Context, *ent.SourceControlQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f SourceControlFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.SourceControlQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.SourceControlQuery", q)
}

// The TraverseSourceControl type is an adapter to allow the use of ordinary function as Traverser.
type TraverseSourceControl func(context.Context, *ent.SourceControlQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseSourceControl) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseSourceControl) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.SourceControlQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.SourceControlQuery", q)
}

// The SystemNetworkStatsFunc type is an adapter to allow the use of ordinary function as a Querier.
type SystemNetworkStatsFunc func(context.Context, *ent.SystemNetworkStatsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f SystemNetworkStatsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.SystemNetworkStatsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.SystemNetworkStatsQuery", q)
}

// The TraverseSystemNetworkStats type is an adapter to allow the use of ordinary function as Traverser.
type TraverseSystemNetworkStats func(context.Context, *ent.SystemNetworkStatsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseSystemNetworkStats) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseSystemNetworkStats) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.SystemNetworkStatsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.SystemNetworkStatsQuery", q)
}

// The TargetCompleteFunc type is an adapter to allow the use of ordinary function as a Querier.
type TargetCompleteFunc func(context.Context, *ent.TargetCompleteQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TargetCompleteFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TargetCompleteQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TargetCompleteQuery", q)
}

// The TraverseTargetComplete type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTargetComplete func(context.Context, *ent.TargetCompleteQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTargetComplete) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTargetComplete) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TargetCompleteQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TargetCompleteQuery", q)
}

// The TargetConfiguredFunc type is an adapter to allow the use of ordinary function as a Querier.
type TargetConfiguredFunc func(context.Context, *ent.TargetConfiguredQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TargetConfiguredFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TargetConfiguredQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TargetConfiguredQuery", q)
}

// The TraverseTargetConfigured type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTargetConfigured func(context.Context, *ent.TargetConfiguredQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTargetConfigured) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTargetConfigured) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TargetConfiguredQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TargetConfiguredQuery", q)
}

// The TargetMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type TargetMetricsFunc func(context.Context, *ent.TargetMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TargetMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TargetMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TargetMetricsQuery", q)
}

// The TraverseTargetMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTargetMetrics func(context.Context, *ent.TargetMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTargetMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTargetMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TargetMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TargetMetricsQuery", q)
}

// The TargetPairFunc type is an adapter to allow the use of ordinary function as a Querier.
type TargetPairFunc func(context.Context, *ent.TargetPairQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TargetPairFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TargetPairQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TargetPairQuery", q)
}

// The TraverseTargetPair type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTargetPair func(context.Context, *ent.TargetPairQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTargetPair) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTargetPair) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TargetPairQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TargetPairQuery", q)
}

// The TestCollectionFunc type is an adapter to allow the use of ordinary function as a Querier.
type TestCollectionFunc func(context.Context, *ent.TestCollectionQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TestCollectionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TestCollectionQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TestCollectionQuery", q)
}

// The TraverseTestCollection type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTestCollection func(context.Context, *ent.TestCollectionQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTestCollection) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTestCollection) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TestCollectionQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TestCollectionQuery", q)
}

// The TestFileFunc type is an adapter to allow the use of ordinary function as a Querier.
type TestFileFunc func(context.Context, *ent.TestFileQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TestFileFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TestFileQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TestFileQuery", q)
}

// The TraverseTestFile type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTestFile func(context.Context, *ent.TestFileQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTestFile) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTestFile) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TestFileQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TestFileQuery", q)
}

// The TestResultBESFunc type is an adapter to allow the use of ordinary function as a Querier.
type TestResultBESFunc func(context.Context, *ent.TestResultBESQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TestResultBESFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TestResultBESQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TestResultBESQuery", q)
}

// The TraverseTestResultBES type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTestResultBES func(context.Context, *ent.TestResultBESQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTestResultBES) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTestResultBES) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TestResultBESQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TestResultBESQuery", q)
}

// The TestSummaryFunc type is an adapter to allow the use of ordinary function as a Querier.
type TestSummaryFunc func(context.Context, *ent.TestSummaryQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TestSummaryFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TestSummaryQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TestSummaryQuery", q)
}

// The TraverseTestSummary type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTestSummary func(context.Context, *ent.TestSummaryQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTestSummary) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTestSummary) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TestSummaryQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TestSummaryQuery", q)
}

// The TimingBreakdownFunc type is an adapter to allow the use of ordinary function as a Querier.
type TimingBreakdownFunc func(context.Context, *ent.TimingBreakdownQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TimingBreakdownFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TimingBreakdownQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TimingBreakdownQuery", q)
}

// The TraverseTimingBreakdown type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTimingBreakdown func(context.Context, *ent.TimingBreakdownQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTimingBreakdown) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTimingBreakdown) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TimingBreakdownQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TimingBreakdownQuery", q)
}

// The TimingChildFunc type is an adapter to allow the use of ordinary function as a Querier.
type TimingChildFunc func(context.Context, *ent.TimingChildQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TimingChildFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TimingChildQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TimingChildQuery", q)
}

// The TraverseTimingChild type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTimingChild func(context.Context, *ent.TimingChildQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTimingChild) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTimingChild) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TimingChildQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TimingChildQuery", q)
}

// The TimingMetricsFunc type is an adapter to allow the use of ordinary function as a Querier.
type TimingMetricsFunc func(context.Context, *ent.TimingMetricsQuery) (ent.Value, error)

// Query calls f(ctx, q).
func (f TimingMetricsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
	if q, ok := q.(*ent.TimingMetricsQuery); ok {
		return f(ctx, q)
	}
	return nil, fmt.Errorf("unexpected query type %T. expect *ent.TimingMetricsQuery", q)
}

// The TraverseTimingMetrics type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTimingMetrics func(context.Context, *ent.TimingMetricsQuery) error

// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTimingMetrics) Intercept(next ent.Querier) ent.Querier {
	return next
}

// Traverse calls f(ctx, q).
func (f TraverseTimingMetrics) Traverse(ctx context.Context, q ent.Query) error {
	if q, ok := q.(*ent.TimingMetricsQuery); ok {
		return f(ctx, q)
	}
	return fmt.Errorf("unexpected query type %T. expect *ent.TimingMetricsQuery", q)
}

// NewQuery returns the generic Query interface for the given typed query.
func NewQuery(q ent.Query) (Query, error) {
	switch q := q.(type) {
	case *ent.ActionCacheStatisticsQuery:
		return &query[*ent.ActionCacheStatisticsQuery, predicate.ActionCacheStatistics, actioncachestatistics.OrderOption]{typ: ent.TypeActionCacheStatistics, tq: q}, nil
	case *ent.ActionDataQuery:
		return &query[*ent.ActionDataQuery, predicate.ActionData, actiondata.OrderOption]{typ: ent.TypeActionData, tq: q}, nil
	case *ent.ActionSummaryQuery:
		return &query[*ent.ActionSummaryQuery, predicate.ActionSummary, actionsummary.OrderOption]{typ: ent.TypeActionSummary, tq: q}, nil
	case *ent.ArtifactMetricsQuery:
		return &query[*ent.ArtifactMetricsQuery, predicate.ArtifactMetrics, artifactmetrics.OrderOption]{typ: ent.TypeArtifactMetrics, tq: q}, nil
	case *ent.BazelInvocationQuery:
		return &query[*ent.BazelInvocationQuery, predicate.BazelInvocation, bazelinvocation.OrderOption]{typ: ent.TypeBazelInvocation, tq: q}, nil
	case *ent.BazelInvocationProblemQuery:
		return &query[*ent.BazelInvocationProblemQuery, predicate.BazelInvocationProblem, bazelinvocationproblem.OrderOption]{typ: ent.TypeBazelInvocationProblem, tq: q}, nil
	case *ent.BlobQuery:
		return &query[*ent.BlobQuery, predicate.Blob, blob.OrderOption]{typ: ent.TypeBlob, tq: q}, nil
	case *ent.BuildQuery:
		return &query[*ent.BuildQuery, predicate.Build, build.OrderOption]{typ: ent.TypeBuild, tq: q}, nil
	case *ent.BuildGraphMetricsQuery:
		return &query[*ent.BuildGraphMetricsQuery, predicate.BuildGraphMetrics, buildgraphmetrics.OrderOption]{typ: ent.TypeBuildGraphMetrics, tq: q}, nil
	case *ent.CumulativeMetricsQuery:
		return &query[*ent.CumulativeMetricsQuery, predicate.CumulativeMetrics, cumulativemetrics.OrderOption]{typ: ent.TypeCumulativeMetrics, tq: q}, nil
	case *ent.DynamicExecutionMetricsQuery:
		return &query[*ent.DynamicExecutionMetricsQuery, predicate.DynamicExecutionMetrics, dynamicexecutionmetrics.OrderOption]{typ: ent.TypeDynamicExecutionMetrics, tq: q}, nil
	case *ent.EvaluationStatQuery:
		return &query[*ent.EvaluationStatQuery, predicate.EvaluationStat, evaluationstat.OrderOption]{typ: ent.TypeEvaluationStat, tq: q}, nil
	case *ent.EventFileQuery:
		return &query[*ent.EventFileQuery, predicate.EventFile, eventfile.OrderOption]{typ: ent.TypeEventFile, tq: q}, nil
	case *ent.ExectionInfoQuery:
		return &query[*ent.ExectionInfoQuery, predicate.ExectionInfo, exectioninfo.OrderOption]{typ: ent.TypeExectionInfo, tq: q}, nil
	case *ent.FilesMetricQuery:
		return &query[*ent.FilesMetricQuery, predicate.FilesMetric, filesmetric.OrderOption]{typ: ent.TypeFilesMetric, tq: q}, nil
	case *ent.GarbageMetricsQuery:
		return &query[*ent.GarbageMetricsQuery, predicate.GarbageMetrics, garbagemetrics.OrderOption]{typ: ent.TypeGarbageMetrics, tq: q}, nil
	case *ent.MemoryMetricsQuery:
		return &query[*ent.MemoryMetricsQuery, predicate.MemoryMetrics, memorymetrics.OrderOption]{typ: ent.TypeMemoryMetrics, tq: q}, nil
	case *ent.MetricsQuery:
		return &query[*ent.MetricsQuery, predicate.Metrics, metrics.OrderOption]{typ: ent.TypeMetrics, tq: q}, nil
	case *ent.MissDetailQuery:
		return &query[*ent.MissDetailQuery, predicate.MissDetail, missdetail.OrderOption]{typ: ent.TypeMissDetail, tq: q}, nil
	case *ent.NamedSetOfFilesQuery:
		return &query[*ent.NamedSetOfFilesQuery, predicate.NamedSetOfFiles, namedsetoffiles.OrderOption]{typ: ent.TypeNamedSetOfFiles, tq: q}, nil
	case *ent.NetworkMetricsQuery:
		return &query[*ent.NetworkMetricsQuery, predicate.NetworkMetrics, networkmetrics.OrderOption]{typ: ent.TypeNetworkMetrics, tq: q}, nil
	case *ent.OutputGroupQuery:
		return &query[*ent.OutputGroupQuery, predicate.OutputGroup, outputgroup.OrderOption]{typ: ent.TypeOutputGroup, tq: q}, nil
	case *ent.PackageLoadMetricsQuery:
		return &query[*ent.PackageLoadMetricsQuery, predicate.PackageLoadMetrics, packageloadmetrics.OrderOption]{typ: ent.TypePackageLoadMetrics, tq: q}, nil
	case *ent.PackageMetricsQuery:
		return &query[*ent.PackageMetricsQuery, predicate.PackageMetrics, packagemetrics.OrderOption]{typ: ent.TypePackageMetrics, tq: q}, nil
	case *ent.RaceStatisticsQuery:
		return &query[*ent.RaceStatisticsQuery, predicate.RaceStatistics, racestatistics.OrderOption]{typ: ent.TypeRaceStatistics, tq: q}, nil
	case *ent.ResourceUsageQuery:
		return &query[*ent.ResourceUsageQuery, predicate.ResourceUsage, resourceusage.OrderOption]{typ: ent.TypeResourceUsage, tq: q}, nil
	case *ent.RunnerCountQuery:
		return &query[*ent.RunnerCountQuery, predicate.RunnerCount, runnercount.OrderOption]{typ: ent.TypeRunnerCount, tq: q}, nil
	case *ent.SourceControlQuery:
		return &query[*ent.SourceControlQuery, predicate.SourceControl, sourcecontrol.OrderOption]{typ: ent.TypeSourceControl, tq: q}, nil
	case *ent.SystemNetworkStatsQuery:
		return &query[*ent.SystemNetworkStatsQuery, predicate.SystemNetworkStats, systemnetworkstats.OrderOption]{typ: ent.TypeSystemNetworkStats, tq: q}, nil
	case *ent.TargetCompleteQuery:
		return &query[*ent.TargetCompleteQuery, predicate.TargetComplete, targetcomplete.OrderOption]{typ: ent.TypeTargetComplete, tq: q}, nil
	case *ent.TargetConfiguredQuery:
		return &query[*ent.TargetConfiguredQuery, predicate.TargetConfigured, targetconfigured.OrderOption]{typ: ent.TypeTargetConfigured, tq: q}, nil
	case *ent.TargetMetricsQuery:
		return &query[*ent.TargetMetricsQuery, predicate.TargetMetrics, targetmetrics.OrderOption]{typ: ent.TypeTargetMetrics, tq: q}, nil
	case *ent.TargetPairQuery:
		return &query[*ent.TargetPairQuery, predicate.TargetPair, targetpair.OrderOption]{typ: ent.TypeTargetPair, tq: q}, nil
	case *ent.TestCollectionQuery:
		return &query[*ent.TestCollectionQuery, predicate.TestCollection, testcollection.OrderOption]{typ: ent.TypeTestCollection, tq: q}, nil
	case *ent.TestFileQuery:
		return &query[*ent.TestFileQuery, predicate.TestFile, testfile.OrderOption]{typ: ent.TypeTestFile, tq: q}, nil
	case *ent.TestResultBESQuery:
		return &query[*ent.TestResultBESQuery, predicate.TestResultBES, testresultbes.OrderOption]{typ: ent.TypeTestResultBES, tq: q}, nil
	case *ent.TestSummaryQuery:
		return &query[*ent.TestSummaryQuery, predicate.TestSummary, testsummary.OrderOption]{typ: ent.TypeTestSummary, tq: q}, nil
	case *ent.TimingBreakdownQuery:
		return &query[*ent.TimingBreakdownQuery, predicate.TimingBreakdown, timingbreakdown.OrderOption]{typ: ent.TypeTimingBreakdown, tq: q}, nil
	case *ent.TimingChildQuery:
		return &query[*ent.TimingChildQuery, predicate.TimingChild, timingchild.OrderOption]{typ: ent.TypeTimingChild, tq: q}, nil
	case *ent.TimingMetricsQuery:
		return &query[*ent.TimingMetricsQuery, predicate.TimingMetrics, timingmetrics.OrderOption]{typ: ent.TypeTimingMetrics, tq: q}, nil
	default:
		return nil, fmt.Errorf("unknown query type %T", q)
	}
}

type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
	typ string
	tq  interface {
		Limit(int) T
		Offset(int) T
		Unique(bool) T
		Order(...R) T
		Where(...P) T
	}
}

func (q query[T, P, R]) Type() string {
	return q.typ
}

func (q query[T, P, R]) Limit(limit int) {
	q.tq.Limit(limit)
}

func (q query[T, P, R]) Offset(offset int) {
	q.tq.Offset(offset)
}

func (q query[T, P, R]) Unique(unique bool) {
	q.tq.Unique(unique)
}

func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
	rs := make([]R, len(orders))
	for i := range orders {
		rs[i] = orders[i]
	}
	q.tq.Order(rs...)
}

func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
	p := make([]P, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	q.tq.Where(p...)
}
