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

package v1alpha1

import (
	v1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

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

// applicationSetLister implements the ApplicationSetLister interface.
type applicationSetLister struct {
	indexer cache.Indexer
}

// NewApplicationSetLister returns a new ApplicationSetLister.
func NewApplicationSetLister(indexer cache.Indexer) ApplicationSetLister {
	return &applicationSetLister{indexer: indexer}
}

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

// ApplicationSets returns an object that can list and get ApplicationSets.
func (s *applicationSetLister) ApplicationSets(namespace string) ApplicationSetNamespaceLister {
	return applicationSetNamespaceLister{indexer: s.indexer, namespace: namespace}
}

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

// applicationSetNamespaceLister implements the ApplicationSetNamespaceLister
// interface.
type applicationSetNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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