class SharedInformerFactoryImpl implements SharedInformerFactory {
  private static final Logger log = LoggerFactory.getLogger(SharedInformerFactoryImpl.class);

  private final List<SharedIndexInformer<?>> informers = new ArrayList<>();

  private final ConcurrentLinkedQueue<SharedInformerEventListener> eventListeners = new ConcurrentLinkedQueue<>();

  private String name;
  private String namespace;

  private final KubernetesClient client;

  public SharedInformerFactoryImpl(KubernetesClient client) {
    this.client = client;
  }

  @Override
  public SharedInformerFactory inNamespace(String namespace) {
    this.namespace = namespace;
    return this;
  }

  @Override
  public SharedInformerFactory withName(String name) {
    this.name = name;
    return this;
  }

  @Override
  public synchronized <T extends HasMetadata> SharedIndexInformer<T> sharedIndexInformerFor(Class<T> apiTypeClass,
      long resyncPeriodInMillis) {<FILL_FUNCTION_BODY>}

  @Override
  public synchronized <T> SharedIndexInformer<T> getExistingSharedIndexInformer(Class<T> apiTypeClass) {
    for (SharedIndexInformer<?> informer : this.informers) {
      if (informer.getApiTypeClass().equals(apiTypeClass)) {
        return (SharedIndexInformer<T>) informer;
      }
    }
    return null;
  }

  @Override
  public synchronized Future<Void> startAllRegisteredInformers() {
    List<CompletableFuture<Void>> startInformerTasks = new ArrayList<>();

    if (!informers.isEmpty()) {
      for (SharedIndexInformer<?> informer : informers) {
        CompletableFuture<Void> future = informer.start().toCompletableFuture();
        startInformerTasks.add(future);
        future.whenComplete((v, t) -> {
          if (t != null) {
            if (this.eventListeners.isEmpty()) {
              log.warn("Failed to start informer {}", informer, t);
            } else {
              this.eventListeners
                  .forEach(listener -> listener.onException(informer, KubernetesClientException.launderThrowable(t)));
            }
          }
        });
      }
    }
    return CompletableFuture.allOf(startInformerTasks.toArray(new CompletableFuture[] {}));
  }

  @Override
  public synchronized void stopAllRegisteredInformers() {
    informers.forEach(SharedIndexInformer::stop);
  }

  @Override
  public void addSharedInformerEventListener(SharedInformerEventListener event) {
    this.eventListeners.add(event);
  }

}

    MixedOperation<T, KubernetesResourceList<T>, Resource<T>> resources = client.resources(apiTypeClass);

    Informable<T> informable = null;

    if (namespace != null) {
      NonNamespaceOperation<T, KubernetesResourceList<T>, Resource<T>> nonNamespaceOp = resources.inNamespace(namespace);
      informable = nonNamespaceOp;
      if (name != null) {
        informable = nonNamespaceOp.withName(name);
      }
    } else if (name != null) {
      informable = resources.withName(name);
    } else {
      informable = resources.inAnyNamespace();
    }

    SharedIndexInformer<T> informer = informable.runnableInformer(resyncPeriodInMillis);
    this.informers.add(informer);
    return informer;
  
<no_super_class>