class KubernetesEndpointSlicesCatalogWatch
		implements Function<KubernetesCatalogWatchContext, List<EndpointNameAndNamespace>> {

	private static final LogAccessor LOG = new LogAccessor(
			LogFactory.getLog(KubernetesEndpointSlicesCatalogWatch.class));

	@Override
	public List<EndpointNameAndNamespace> apply(KubernetesCatalogWatchContext context) {<FILL_FUNCTION_BODY>}

	private List<V1EndpointSlice> endpointSlices(DiscoveryV1Api api, Map<String, String> labels) {
		try {
			return api.listEndpointSliceForAllNamespaces(null, null, null, labelSelector(labels), null, null, null,
					null, null, null, null).getItems();
		}
		catch (ApiException e) {
			LOG.warn(e, () -> "can not list endpoint slices in all namespaces");
			return Collections.emptyList();
		}
	}

	private List<V1EndpointSlice> namespacedEndpointSlices(DiscoveryV1Api api, String namespace,
			Map<String, String> labels) {
		try {
			return api.listNamespacedEndpointSlice(namespace, null, null, null, null, labelSelector(labels), null, null,
					null, null, null, null).getItems();
		}
		catch (ApiException e) {
			LOG.warn(e, () -> "can not list endpoint slices in namespace " + namespace);
			return Collections.emptyList();
		}
	}

}


		List<V1EndpointSlice> endpointSlices;
		DiscoveryV1Api api = new DiscoveryV1Api(context.apiClient());

		if (context.properties().allNamespaces()) {
			LOG.debug(() -> "discovering endpoint slices in all namespaces");
			endpointSlices = endpointSlices(api, context.properties().serviceLabels());
		}
		else if (!context.properties().namespaces().isEmpty()) {
			LOG.debug(() -> "discovering endpoint slices in " + context.properties().namespaces());
			List<V1EndpointSlice> inner = new ArrayList<>(context.properties().namespaces().size());
			context.properties().namespaces().forEach(namespace -> inner
					.addAll(namespacedEndpointSlices(api, namespace, context.properties().serviceLabels())));
			endpointSlices = inner;
		}
		else {
			String namespace = KubernetesClientUtils.getApplicationNamespace(null, "catalog-watch",
					context.namespaceProvider());
			LOG.debug(() -> "discovering endpoint slices in namespace : " + namespace);
			endpointSlices = namespacedEndpointSlices(api, namespace, context.properties().serviceLabels());
		}

		Stream<V1ObjectReference> references = endpointSlices.stream().map(V1EndpointSlice::getEndpoints)
				.flatMap(List::stream).map(V1Endpoint::getTargetRef);

		return KubernetesCatalogWatchContext.state(references);

	
<no_super_class>