class AddCustomResourceDefinitionResourceDecorator extends ResourceProvidingDecorator<KubernetesListBuilder> {

  private String name;
  private String apiGroup;
  private String kind;

  private String scope;
  private String[] shortNames;
  private String plural;
  private String singular;
  private String[] annotations;
  private String[] labels;

  public AddCustomResourceDefinitionResourceDecorator(String name, String apiGroup, String kind,
      String scope, String[] shortNames, String plural, String singular, String[] annotations, String[] labels) {
    this.name = name;
    this.apiGroup = apiGroup;
    this.kind = kind;
    this.scope = scope;
    this.shortNames = shortNames;
    this.plural = plural;
    this.singular = singular;
    this.annotations = annotations;
    this.labels = labels;
  }

  @Override
  public void visit(KubernetesListBuilder list) {<FILL_FUNCTION_BODY>}

  @Override
  public Class<? extends Decorator>[] before() {
    return new Class[] { AddCustomResourceDefinitionVersionDecorator.class,
        CustomResourceDefinitionDecorator.class };
  }

  @Override
  public String toString() {
    return getClass().getName() + " [apiGroup=" + apiGroup + ", kind=" + kind + ", name=" + name + ", plural=" + plural
        + ", scope=" + scope + "]";
  }
}

    boolean exists = list.buildItems().stream().anyMatch(i -> i.getKind().equals("CustomResourceDefinition")
        && i.getMetadata().getName().equals(name)
        && ApiVersionUtil.trimVersion(i.getApiVersion()).equals("v1beta1"));

    if (!exists) {
      list.addToItems(new CustomResourceDefinitionBuilder()
          .withNewMetadata()
          .withName(name)
          .withAnnotations(toMap(annotations))
          .withLabels(toMap(labels))
          .endMetadata()
          .withNewSpec()
          .withScope(scope)
          .withGroup(apiGroup)
          .withNewNames()
          .withKind(kind)
          .withShortNames(shortNames)
          .withPlural(plural)
          .withSingular(singular)
          .endNames()
          .endSpec()
          .build());
    }
  
<methods>public non-sealed void <init>() <variables>