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

package v1alpha1

import (
	v1alpha1 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// ResourceBindingLister helps list ResourceBindings.
// All objects returned here must be treated as read-only.
type ResourceBindingLister interface {
	// List lists all ResourceBindings in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.ResourceBinding, err error)
	// ResourceBindings returns an object that can list and get ResourceBindings.
	ResourceBindings(namespace string) ResourceBindingNamespaceLister
	ResourceBindingListerExpansion
}

// resourceBindingLister implements the ResourceBindingLister interface.
type resourceBindingLister struct {
	indexer cache.Indexer
}

// NewResourceBindingLister returns a new ResourceBindingLister.
func NewResourceBindingLister(indexer cache.Indexer) ResourceBindingLister {
	return &resourceBindingLister{indexer: indexer}
}

// List lists all ResourceBindings in the indexer.
func (s *resourceBindingLister) List(selector labels.Selector) (ret []*v1alpha1.ResourceBinding, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.ResourceBinding))
	})
	return ret, err
}

// ResourceBindings returns an object that can list and get ResourceBindings.
func (s *resourceBindingLister) ResourceBindings(namespace string) ResourceBindingNamespaceLister {
	return resourceBindingNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// ResourceBindingNamespaceLister helps list and get ResourceBindings.
// All objects returned here must be treated as read-only.
type ResourceBindingNamespaceLister interface {
	// List lists all ResourceBindings in the indexer for a given namespace.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.ResourceBinding, err error)
	// Get retrieves the ResourceBinding from the indexer for a given namespace and name.
	// Objects returned here must be treated as read-only.
	Get(name string) (*v1alpha1.ResourceBinding, error)
	ResourceBindingNamespaceListerExpansion
}

// resourceBindingNamespaceLister implements the ResourceBindingNamespaceLister
// interface.
type resourceBindingNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

// List lists all ResourceBindings in the indexer for a given namespace.
func (s resourceBindingNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ResourceBinding, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.ResourceBinding))
	})
	return ret, err
}

// Get retrieves the ResourceBinding from the indexer for a given namespace and name.
func (s resourceBindingNamespaceLister) Get(name string) (*v1alpha1.ResourceBinding, error) {
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(v1alpha1.Resource("resourcebinding"), name)
	}
	return obj.(*v1alpha1.ResourceBinding), nil
}
