class ResourceHandlerImpl<T extends HasMetadata, V extends VisitableBuilder<T, V>> implements ResourceHandler<T, V> {

  private final ResourceDefinitionContext context;
  private final Class<T> type;
  private final Class<V> builderClass;
  private final Class<? extends KubernetesResourceList<T>> defaultListClass;
  private final Function<Client, HasMetadataOperation<T, ?, Resource<T>>> operationConstructor;

  ResourceHandlerImpl(Class<T> type, Function<Client, HasMetadataOperation<T, ?, Resource<T>>> operationConstructor) {
    this.type = type;
    this.context = ResourceDefinitionContext.fromResourceType(type);
    this.builderClass = KubernetesResourceUtil.inferBuilderType(type);
    this.defaultListClass = (Class<? extends KubernetesResourceList<T>>) KubernetesResourceUtil.inferListType(type);
    this.operationConstructor = operationConstructor;
  }

  ResourceHandlerImpl(Class<T> type, Class<? extends KubernetesResourceList<T>> listClass, ResourceDefinitionContext context) {
    this.type = type;
    this.context = context;
    this.defaultListClass = listClass;
    this.builderClass = KubernetesResourceUtil.inferBuilderType(type);
    this.operationConstructor = null;
  }

  @Override
  public V edit(T item) {<FILL_FUNCTION_BODY>}

  @Override
  public <L extends KubernetesResourceList<T>> HasMetadataOperation<T, L, Resource<T>> operation(Client client,
      Class<L> listType) {
    if (operationConstructor != null) {
      if (listType != null && !listType.isAssignableFrom(defaultListClass)) {
        throw new IllegalArgumentException(String.format("Handler type %s with list %s not compatible with %s", type,
            defaultListClass.getName(), listType.getName()));
      }
      return (HasMetadataOperation<T, L, Resource<T>>) operationConstructor.apply(client);
    }
    return new HasMetadataOperationsImpl<>(client, context, type, (Class) Utils.getNonNullOrElse(listType, defaultListClass));
  }

  @Override
  public boolean hasOperation() {
    return operationConstructor != null;
  }

}

    if (this.builderClass == null) {
      throw new KubernetesClientException(String.format("Cannot edit %s with visitors, no builder was found", type.getName()));
    }
    try {
      return this.builderClass.getDeclaredConstructor(item.getClass()).newInstance(item);
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
        | NoSuchMethodException | SecurityException e) {
      throw KubernetesClientException.launderThrowable(e);
    }
  
<no_super_class>