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

package v1alpha2

import (
	v1alpha2 "istio.io/client-go/pkg/apis/config/v1alpha2"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// HandlerLister helps list Handlers.
type HandlerLister interface {
	// List lists all Handlers in the indexer.
	List(selector labels.Selector) (ret []*v1alpha2.Handler, err error)
	// Handlers returns an object that can list and get Handlers.
	Handlers(namespace string) HandlerNamespaceLister
	HandlerListerExpansion
}

// handlerLister implements the HandlerLister interface.
type handlerLister struct {
	indexer cache.Indexer
}

// NewHandlerLister returns a new HandlerLister.
func NewHandlerLister(indexer cache.Indexer) HandlerLister {
	return &handlerLister{indexer: indexer}
}

// List lists all Handlers in the indexer.
func (s *handlerLister) List(selector labels.Selector) (ret []*v1alpha2.Handler, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha2.Handler))
	})
	return ret, err
}

// Handlers returns an object that can list and get Handlers.
func (s *handlerLister) Handlers(namespace string) HandlerNamespaceLister {
	return handlerNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// HandlerNamespaceLister helps list and get Handlers.
type HandlerNamespaceLister interface {
	// List lists all Handlers in the indexer for a given namespace.
	List(selector labels.Selector) (ret []*v1alpha2.Handler, err error)
	// Get retrieves the Handler from the indexer for a given namespace and name.
	Get(name string) (*v1alpha2.Handler, error)
	HandlerNamespaceListerExpansion
}

// handlerNamespaceLister implements the HandlerNamespaceLister
// interface.
type handlerNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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