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

package v1alpha1

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

// ClusterPropagationPolicyLister helps list ClusterPropagationPolicies.
// All objects returned here must be treated as read-only.
type ClusterPropagationPolicyLister interface {
	// List lists all ClusterPropagationPolicies in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.ClusterPropagationPolicy, err error)
	// Get retrieves the ClusterPropagationPolicy from the index for a given name.
	// Objects returned here must be treated as read-only.
	Get(name string) (*v1alpha1.ClusterPropagationPolicy, error)
	ClusterPropagationPolicyListerExpansion
}

// clusterPropagationPolicyLister implements the ClusterPropagationPolicyLister interface.
type clusterPropagationPolicyLister struct {
	indexer cache.Indexer
}

// NewClusterPropagationPolicyLister returns a new ClusterPropagationPolicyLister.
func NewClusterPropagationPolicyLister(indexer cache.Indexer) ClusterPropagationPolicyLister {
	return &clusterPropagationPolicyLister{indexer: indexer}
}

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

// Get retrieves the ClusterPropagationPolicy from the index for a given name.
func (s *clusterPropagationPolicyLister) Get(name string) (*v1alpha1.ClusterPropagationPolicy, error) {
	obj, exists, err := s.indexer.GetByKey(name)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(v1alpha1.Resource("clusterpropagationpolicy"), name)
	}
	return obj.(*v1alpha1.ClusterPropagationPolicy), nil
}
