/*
Copyright The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Code generated by informer-gen. DO NOT EDIT.

package v1beta1

import (
	context "context"
	time "time"

	apischedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	runtime "k8s.io/apimachinery/pkg/runtime"
	schema "k8s.io/apimachinery/pkg/runtime/schema"
	watch "k8s.io/apimachinery/pkg/watch"
	internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
	kubernetes "k8s.io/client-go/kubernetes"
	schedulingv1beta1 "k8s.io/client-go/listers/scheduling/v1beta1"
	cache "k8s.io/client-go/tools/cache"
)

// PriorityClassInformer provides access to a shared informer and lister for
// PriorityClasses. Prefer using the type-safe variant (see [TypedPriorityClassInformer]).
type PriorityClassInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() schedulingv1beta1.PriorityClassLister
}

// TypedPriorityClassInformer provides access to a shared informer and lister for
// PriorityClasses, including the type-safe TypedInformer variant.
// It is a superset of PriorityClassInformer.
type TypedPriorityClassInformer interface {
	Informer() cache.SharedIndexInformer
	TypedInformer() PriorityClassIndexInformer
	Lister() schedulingv1beta1.PriorityClassLister
}

// PriorityClassIndexInformer is a wrapper around the underlying [cache.SharedIndexInformer]
// with type-safe variants of several methods.
type PriorityClassIndexInformer cache.TypedSharedIndexInformer[*apischedulingv1beta1.PriorityClass]

// PriorityClassHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for PriorityClass.
type PriorityClassHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apischedulingv1beta1.PriorityClass]

// PriorityClassDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for PriorityClass.
type PriorityClassDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apischedulingv1beta1.PriorityClass]

// PriorityClassFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for PriorityClass.
type PriorityClassFilteringHandler = cache.TypedFilteringResourceEventHandler[*apischedulingv1beta1.PriorityClass]

// PriorityClassIndexers is a specialization of [cache.TypedIndexers] for PriorityClass.
type PriorityClassIndexers = cache.TypedIndexers[*apischedulingv1beta1.PriorityClass]

// DeletedPriorityClass is a specialization of [cache.DeletedObject] for PriorityClass.
type DeletedPriorityClass = cache.DeletedObject[*apischedulingv1beta1.PriorityClass]

type priorityClassInformer struct {
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
}

// NewPriorityClassInformer constructs a new informer for PriorityClass type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
// If you really need an independent one, prefer using the type-safe variant (see [NewTypedPriorityClassInformer]).
func NewPriorityClassInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewPriorityClassInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers})
}

// NewTypedPriorityClassInformer constructs a new informer for PriorityClass type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTypedPriorityClassInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers PriorityClassIndexers) PriorityClassIndexInformer {
	return NewTypedPriorityClassInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)})
}

// NewFilteredPriorityClassInformer constructs a new informer for PriorityClass type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
// If you really need an independent one, prefer using the type-safe variant (see [NewTypedFilteredPriorityClassInformer]).
func NewFilteredPriorityClassInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return NewTypedPriorityClassInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions})
}

// NewTypedFilteredPriorityClassInformer constructs a new informer for PriorityClass type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTypedFilteredPriorityClassInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers PriorityClassIndexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) PriorityClassIndexInformer {
	return NewTypedPriorityClassInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers), TweakListOptions: tweakListOptions})
}

// NewPriorityClassInformerWithOptions constructs a new informer for PriorityClass type with additional options.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
// If you really need an independent one, prefer using the type-safe variant (see [NewTypedPriorityClassInformerWithOptions]).
func NewPriorityClassInformerWithOptions(client kubernetes.Interface, options internalinterfaces.InformerOptions) cache.SharedIndexInformer {
	return NewTypedPriorityClassInformerWithOptions(client, options)
}

// NewTypedPriorityClassInformerWithOptions constructs a new informer for PriorityClass type with additional options.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewTypedPriorityClassInformerWithOptions(client kubernetes.Interface, options internalinterfaces.InformerOptions) PriorityClassIndexInformer {
	gvr := schema.GroupVersionResource{Group: "scheduling.k8s.io", Version: "v1beta1", Resource: "priorityclasss"}
	identifier := options.InformerName.WithResource(gvr)
	tweakListOptions := options.TweakListOptions
	return cache.NewTypedSharedIndexInformer[*apischedulingv1beta1.PriorityClass](cache.NewSharedIndexInformerWithOptions(
		cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
			ListFunc: func(opts v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.SchedulingV1beta1().PriorityClasses().List(context.Background(), opts)
			},
			WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.SchedulingV1beta1().PriorityClasses().Watch(context.Background(), opts)
			},
			ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.SchedulingV1beta1().PriorityClasses().List(ctx, opts)
			},
			WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.SchedulingV1beta1().PriorityClasses().Watch(ctx, opts)
			},
		}, client),
		&apischedulingv1beta1.PriorityClass{},
		cache.SharedIndexInformerOptions{
			ResyncPeriod: options.ResyncPeriod,
			Indexers:     options.Indexers,
			Identifier:   identifier,
		},
	))
}

func (f *priorityClassInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
	return NewTypedPriorityClassInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions})
}

func (f *priorityClassInformer) Informer() cache.SharedIndexInformer {
	return f.TypedInformer()
}

func (f *priorityClassInformer) TypedInformer() PriorityClassIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apischedulingv1beta1.PriorityClass](f.factory.InformerFor(&apischedulingv1beta1.PriorityClass{}, f.defaultInformer))
}

func (f *priorityClassInformer) Lister() schedulingv1beta1.PriorityClassLister {
	return schedulingv1beta1.NewPriorityClassLister(f.Informer().GetIndexer())
}

// ToTypedPriorityClassInformer converts an untyped informer into a TypedPriorityClassInformer.
//
// WARNING: this conversion is only safe if the informer handles objects of type
// *PriorityClass. If that is not the case, calling type-safe methods of the returned
// TypedPriorityClassInformer leads to runtime panics. A safer alternative is to pass
// around a TypedPriorityClassInformer instances that was obtained from a
// SharedInformerFactory.
func ToTypedPriorityClassInformer(informer PriorityClassInformer) TypedPriorityClassInformer {
	if informer, ok := informer.(TypedPriorityClassInformer); ok {
		return informer
	}
	return &priorityClassTypedInformerAdapter{informer}
}

type priorityClassTypedInformerAdapter struct {
	PriorityClassInformer
}

func (a *priorityClassTypedInformerAdapter) TypedInformer() PriorityClassIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apischedulingv1beta1.PriorityClass](a.Informer())
}

// ToPriorityClassIndexInformer converts an untyped informer into a PriorityClassIndexInformer.
//
// WARNING: this conversion is only safe if the informer handles objects of type
// *PriorityClass. If that is not the case, calling type-safe methods of the returned
// PriorityClassIndexInformer leads to runtime panics. A safer alternative is to pass
// around a PriorityClassIndexInformer instances that was obtained from a
// SharedInformerFactory.
func ToPriorityClassIndexInformer(informer cache.SharedIndexInformer) PriorityClassIndexInformer {
	if informer, ok := informer.(PriorityClassIndexInformer); ok {
		return informer
	}
	return cache.NewTypedSharedIndexInformer[*apischedulingv1beta1.PriorityClass](informer)
}
