/*
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 v1

import (
	context "context"
	time "time"

	apicorev1 "k8s.io/api/core/v1"
	metav1 "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"
	corev1 "k8s.io/client-go/listers/core/v1"
	cache "k8s.io/client-go/tools/cache"
)

// LimitRangeInformer provides access to a shared informer and lister for
// LimitRanges. Prefer using the type-safe variant (see [TypedLimitRangeInformer]).
type LimitRangeInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() corev1.LimitRangeLister
}

// TypedLimitRangeInformer provides access to a shared informer and lister for
// LimitRanges, including the type-safe TypedInformer variant.
// It is a superset of LimitRangeInformer.
type TypedLimitRangeInformer interface {
	Informer() cache.SharedIndexInformer
	TypedInformer() LimitRangeIndexInformer
	Lister() corev1.LimitRangeLister
}

// LimitRangeIndexInformer is a wrapper around the underlying [cache.SharedIndexInformer]
// with type-safe variants of several methods.
type LimitRangeIndexInformer cache.TypedSharedIndexInformer[*apicorev1.LimitRange]

// LimitRangeHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for LimitRange.
type LimitRangeHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apicorev1.LimitRange]

// LimitRangeDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for LimitRange.
type LimitRangeDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apicorev1.LimitRange]

// LimitRangeFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for LimitRange.
type LimitRangeFilteringHandler = cache.TypedFilteringResourceEventHandler[*apicorev1.LimitRange]

// LimitRangeIndexers is a specialization of [cache.TypedIndexers] for LimitRange.
type LimitRangeIndexers = cache.TypedIndexers[*apicorev1.LimitRange]

// DeletedLimitRange is a specialization of [cache.DeletedObject] for LimitRange.
type DeletedLimitRange = cache.DeletedObject[*apicorev1.LimitRange]

type limitRangeInformer struct {
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
	namespace        string
}

// NewLimitRangeInformer constructs a new informer for LimitRange 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 [NewTypedLimitRangeInformer]).
func NewLimitRangeInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewLimitRangeInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers})
}

// NewTypedLimitRangeInformer constructs a new informer for LimitRange 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 NewTypedLimitRangeInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers LimitRangeIndexers) LimitRangeIndexInformer {
	return NewTypedLimitRangeInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)})
}

// NewFilteredLimitRangeInformer constructs a new informer for LimitRange 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 [NewTypedFilteredLimitRangeInformer]).
func NewFilteredLimitRangeInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return NewTypedLimitRangeInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions})
}

// NewTypedFilteredLimitRangeInformer constructs a new informer for LimitRange 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 NewTypedFilteredLimitRangeInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers LimitRangeIndexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) LimitRangeIndexInformer {
	return NewTypedLimitRangeInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers), TweakListOptions: tweakListOptions})
}

// NewLimitRangeInformerWithOptions constructs a new informer for LimitRange 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 [NewTypedLimitRangeInformerWithOptions]).
func NewLimitRangeInformerWithOptions(client kubernetes.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer {
	return NewTypedLimitRangeInformerWithOptions(client, namespace, options)
}

// NewTypedLimitRangeInformerWithOptions constructs a new informer for LimitRange 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 NewTypedLimitRangeInformerWithOptions(client kubernetes.Interface, namespace string, options internalinterfaces.InformerOptions) LimitRangeIndexInformer {
	gvr := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "limitranges"}
	identifier := options.InformerName.WithResource(gvr)
	tweakListOptions := options.TweakListOptions
	return cache.NewTypedSharedIndexInformer[*apicorev1.LimitRange](cache.NewSharedIndexInformerWithOptions(
		cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
			ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.CoreV1().LimitRanges(namespace).List(context.Background(), opts)
			},
			WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.CoreV1().LimitRanges(namespace).Watch(context.Background(), opts)
			},
			ListWithContextFunc: func(ctx context.Context, opts metav1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.CoreV1().LimitRanges(namespace).List(ctx, opts)
			},
			WatchFuncWithContext: func(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.CoreV1().LimitRanges(namespace).Watch(ctx, opts)
			},
		}, client),
		&apicorev1.LimitRange{},
		cache.SharedIndexInformerOptions{
			ResyncPeriod: options.ResyncPeriod,
			Indexers:     options.Indexers,
			Identifier:   identifier,
		},
	))
}

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

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

func (f *limitRangeInformer) TypedInformer() LimitRangeIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apicorev1.LimitRange](f.factory.InformerFor(&apicorev1.LimitRange{}, f.defaultInformer))
}

func (f *limitRangeInformer) Lister() corev1.LimitRangeLister {
	return corev1.NewLimitRangeLister(f.Informer().GetIndexer())
}

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

type limitRangeTypedInformerAdapter struct {
	LimitRangeInformer
}

func (a *limitRangeTypedInformerAdapter) TypedInformer() LimitRangeIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apicorev1.LimitRange](a.Informer())
}

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