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

package v1

import (
	v1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// RayJobLister helps list RayJobs.
// All objects returned here must be treated as read-only.
type RayJobLister interface {
	// List lists all RayJobs in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1.RayJob, err error)
	// RayJobs returns an object that can list and get RayJobs.
	RayJobs(namespace string) RayJobNamespaceLister
	RayJobListerExpansion
}

// rayJobLister implements the RayJobLister interface.
type rayJobLister struct {
	indexer cache.Indexer
}

// NewRayJobLister returns a new RayJobLister.
func NewRayJobLister(indexer cache.Indexer) RayJobLister {
	return &rayJobLister{indexer: indexer}
}

// List lists all RayJobs in the indexer.
func (s *rayJobLister) List(selector labels.Selector) (ret []*v1.RayJob, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.RayJob))
	})
	return ret, err
}

// RayJobs returns an object that can list and get RayJobs.
func (s *rayJobLister) RayJobs(namespace string) RayJobNamespaceLister {
	return rayJobNamespaceLister{indexer: s.indexer, namespace: namespace}
}

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

// rayJobNamespaceLister implements the RayJobNamespaceLister
// interface.
type rayJobNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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