class ResourceDefinitionContext {
  protected String group;
  protected boolean namespaced;
  protected String plural;
  protected String version;
  protected String kind;

  public String getGroup() {
    return group;
  }

  public String getPlural() {
    return plural;
  }

  public String getVersion() {
    return version;
  }

  public String getKind() {
    return kind;
  }

  public boolean isNamespaceScoped() {
    return namespaced;
  }

  protected void validate() {
    if (plural == null) {
      if (kind == null) {
        throw new IllegalArgumentException("Neither kind nor plural was set, at least one is required");
      }
      plural = Utils.getPluralFromKind(kind);
    }
  }

  public static ResourceDefinitionContext fromResourceType(Class<? extends KubernetesResource> resource) {<FILL_FUNCTION_BODY>}

  public static ResourceDefinitionContext fromApiResource(String apiVersion, APIResource resource) {
    return new Builder()
        .withGroup(Optional.ofNullable(ApiVersionUtil.trimGroupOrNull(apiVersion)).orElse(""))
        .withVersion(ApiVersionUtil.trimVersion(apiVersion))
        .withNamespaced(Boolean.TRUE.equals(resource.getNamespaced()))
        .withPlural(resource.getName())
        .withKind(resource.getKind())
        .build();
  }

  public static class Builder {
    private final ResourceDefinitionContext resourceDefinitionContext;

    public Builder() {
      this.resourceDefinitionContext = new ResourceDefinitionContext();
    }

    public Builder withGroup(String group) {
      this.resourceDefinitionContext.group = group;
      return this;
    }

    public Builder withNamespaced(boolean namespaced) {
      this.resourceDefinitionContext.namespaced = namespaced;
      return this;
    }

    public Builder withPlural(String plural) {
      this.resourceDefinitionContext.plural = plural;
      return this;
    }

    public Builder withVersion(String version) {
      this.resourceDefinitionContext.version = version;
      return this;
    }

    public Builder withKind(String kind) {
      this.resourceDefinitionContext.kind = kind;
      return this;
    }

    public ResourceDefinitionContext build() {
      this.resourceDefinitionContext.validate();
      return this.resourceDefinitionContext;
    }
  }

}

    try {
      return new Builder()
          .withGroup(HasMetadata.getGroup(resource))
          .withVersion(HasMetadata.getVersion(resource))
          .withNamespaced(Utils.isResourceNamespaced(resource))
          .withPlural(HasMetadata.getPlural(resource))
          .withKind(HasMetadata.getKind(resource))
          .build();
    } catch (IllegalArgumentException e) {
      throw new KubernetesClientException(
          String.format("%s is not annotated appropriately: %s", resource.getName(), e.getMessage()), e);
    }
  
<no_super_class>