All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.kubernetes.client.openapi.models.V1RoleBindingFluent Maven / Gradle / Ivy

There is a newer version: 22.0.0
Show newest version
package io.kubernetes.client.openapi.models;

import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.function.Predicate;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.util.Collection;
import java.lang.Object;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class V1RoleBindingFluent> extends BaseFluent{
  public V1RoleBindingFluent() {
  }
  
  public V1RoleBindingFluent(V1RoleBinding instance) {
    this.copyInstance(instance);
  }
  private String apiVersion;
  private String kind;
  private V1ObjectMetaBuilder metadata;
  private V1RoleRefBuilder roleRef;
  private ArrayList subjects;
  
  protected void copyInstance(V1RoleBinding instance) {
    instance = (instance != null ? instance : new V1RoleBinding());
    if (instance != null) {
          this.withApiVersion(instance.getApiVersion());
          this.withKind(instance.getKind());
          this.withMetadata(instance.getMetadata());
          this.withRoleRef(instance.getRoleRef());
          this.withSubjects(instance.getSubjects());
        }
  }
  
  public String getApiVersion() {
    return this.apiVersion;
  }
  
  public A withApiVersion(String apiVersion) {
    this.apiVersion = apiVersion;
    return (A) this;
  }
  
  public boolean hasApiVersion() {
    return this.apiVersion != null;
  }
  
  public String getKind() {
    return this.kind;
  }
  
  public A withKind(String kind) {
    this.kind = kind;
    return (A) this;
  }
  
  public boolean hasKind() {
    return this.kind != null;
  }
  
  public V1ObjectMeta buildMetadata() {
    return this.metadata != null ? this.metadata.build() : null;
  }
  
  public A withMetadata(V1ObjectMeta metadata) {
    this._visitables.remove("metadata");
    if (metadata != null) {
        this.metadata = new V1ObjectMetaBuilder(metadata);
        this._visitables.get("metadata").add(this.metadata);
    } else {
        this.metadata = null;
        this._visitables.get("metadata").remove(this.metadata);
    }
    return (A) this;
  }
  
  public boolean hasMetadata() {
    return this.metadata != null;
  }
  
  public MetadataNested withNewMetadata() {
    return new MetadataNested(null);
  }
  
  public MetadataNested withNewMetadataLike(V1ObjectMeta item) {
    return new MetadataNested(item);
  }
  
  public MetadataNested editMetadata() {
    return withNewMetadataLike(java.util.Optional.ofNullable(buildMetadata()).orElse(null));
  }
  
  public MetadataNested editOrNewMetadata() {
    return withNewMetadataLike(java.util.Optional.ofNullable(buildMetadata()).orElse(new V1ObjectMetaBuilder().build()));
  }
  
  public MetadataNested editOrNewMetadataLike(V1ObjectMeta item) {
    return withNewMetadataLike(java.util.Optional.ofNullable(buildMetadata()).orElse(item));
  }
  
  public V1RoleRef buildRoleRef() {
    return this.roleRef != null ? this.roleRef.build() : null;
  }
  
  public A withRoleRef(V1RoleRef roleRef) {
    this._visitables.remove("roleRef");
    if (roleRef != null) {
        this.roleRef = new V1RoleRefBuilder(roleRef);
        this._visitables.get("roleRef").add(this.roleRef);
    } else {
        this.roleRef = null;
        this._visitables.get("roleRef").remove(this.roleRef);
    }
    return (A) this;
  }
  
  public boolean hasRoleRef() {
    return this.roleRef != null;
  }
  
  public RoleRefNested withNewRoleRef() {
    return new RoleRefNested(null);
  }
  
  public RoleRefNested withNewRoleRefLike(V1RoleRef item) {
    return new RoleRefNested(item);
  }
  
  public RoleRefNested editRoleRef() {
    return withNewRoleRefLike(java.util.Optional.ofNullable(buildRoleRef()).orElse(null));
  }
  
  public RoleRefNested editOrNewRoleRef() {
    return withNewRoleRefLike(java.util.Optional.ofNullable(buildRoleRef()).orElse(new V1RoleRefBuilder().build()));
  }
  
  public RoleRefNested editOrNewRoleRefLike(V1RoleRef item) {
    return withNewRoleRefLike(java.util.Optional.ofNullable(buildRoleRef()).orElse(item));
  }
  
  public A addToSubjects(int index,RbacV1Subject item) {
    if (this.subjects == null) {this.subjects = new ArrayList();}
    RbacV1SubjectBuilder builder = new RbacV1SubjectBuilder(item);
    if (index < 0 || index >= subjects.size()) { _visitables.get("subjects").add(builder); subjects.add(builder); } else { _visitables.get("subjects").add(index, builder); subjects.add(index, builder);}
    return (A)this;
  }
  
  public A setToSubjects(int index,RbacV1Subject item) {
    if (this.subjects == null) {this.subjects = new ArrayList();}
    RbacV1SubjectBuilder builder = new RbacV1SubjectBuilder(item);
    if (index < 0 || index >= subjects.size()) { _visitables.get("subjects").add(builder); subjects.add(builder); } else { _visitables.get("subjects").set(index, builder); subjects.set(index, builder);}
    return (A)this;
  }
  
  public A addToSubjects(io.kubernetes.client.openapi.models.RbacV1Subject... items) {
    if (this.subjects == null) {this.subjects = new ArrayList();}
    for (RbacV1Subject item : items) {RbacV1SubjectBuilder builder = new RbacV1SubjectBuilder(item);_visitables.get("subjects").add(builder);this.subjects.add(builder);} return (A)this;
  }
  
  public A addAllToSubjects(Collection items) {
    if (this.subjects == null) {this.subjects = new ArrayList();}
    for (RbacV1Subject item : items) {RbacV1SubjectBuilder builder = new RbacV1SubjectBuilder(item);_visitables.get("subjects").add(builder);this.subjects.add(builder);} return (A)this;
  }
  
  public A removeFromSubjects(io.kubernetes.client.openapi.models.RbacV1Subject... items) {
    if (this.subjects == null) return (A)this;
    for (RbacV1Subject item : items) {RbacV1SubjectBuilder builder = new RbacV1SubjectBuilder(item);_visitables.get("subjects").remove(builder); this.subjects.remove(builder);} return (A)this;
  }
  
  public A removeAllFromSubjects(Collection items) {
    if (this.subjects == null) return (A)this;
    for (RbacV1Subject item : items) {RbacV1SubjectBuilder builder = new RbacV1SubjectBuilder(item);_visitables.get("subjects").remove(builder); this.subjects.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromSubjects(Predicate predicate) {
    if (subjects == null) return (A) this;
    final Iterator each = subjects.iterator();
    final List visitables = _visitables.get("subjects");
    while (each.hasNext()) {
      RbacV1SubjectBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildSubjects() {
    return this.subjects != null ? build(subjects) : null;
  }
  
  public RbacV1Subject buildSubject(int index) {
    return this.subjects.get(index).build();
  }
  
  public RbacV1Subject buildFirstSubject() {
    return this.subjects.get(0).build();
  }
  
  public RbacV1Subject buildLastSubject() {
    return this.subjects.get(subjects.size() - 1).build();
  }
  
  public RbacV1Subject buildMatchingSubject(Predicate predicate) {
      for (RbacV1SubjectBuilder item : subjects) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingSubject(Predicate predicate) {
      for (RbacV1SubjectBuilder item : subjects) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withSubjects(List subjects) {
    if (this.subjects != null) {
      this._visitables.get("subjects").clear();
    }
    if (subjects != null) {
        this.subjects = new ArrayList();
        for (RbacV1Subject item : subjects) {
          this.addToSubjects(item);
        }
    } else {
      this.subjects = null;
    }
    return (A) this;
  }
  
  public A withSubjects(io.kubernetes.client.openapi.models.RbacV1Subject... subjects) {
    if (this.subjects != null) {
        this.subjects.clear();
        _visitables.remove("subjects");
    }
    if (subjects != null) {
      for (RbacV1Subject item : subjects) {
        this.addToSubjects(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasSubjects() {
    return this.subjects != null && !this.subjects.isEmpty();
  }
  
  public SubjectsNested addNewSubject() {
    return new SubjectsNested(-1, null);
  }
  
  public SubjectsNested addNewSubjectLike(RbacV1Subject item) {
    return new SubjectsNested(-1, item);
  }
  
  public SubjectsNested setNewSubjectLike(int index,RbacV1Subject item) {
    return new SubjectsNested(index, item);
  }
  
  public SubjectsNested editSubject(int index) {
    if (subjects.size() <= index) throw new RuntimeException("Can't edit subjects. Index exceeds size.");
    return setNewSubjectLike(index, buildSubject(index));
  }
  
  public SubjectsNested editFirstSubject() {
    if (subjects.size() == 0) throw new RuntimeException("Can't edit first subjects. The list is empty.");
    return setNewSubjectLike(0, buildSubject(0));
  }
  
  public SubjectsNested editLastSubject() {
    int index = subjects.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last subjects. The list is empty.");
    return setNewSubjectLike(index, buildSubject(index));
  }
  
  public SubjectsNested editMatchingSubject(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1ObjectMetaFluent> implements Nested{
    MetadataNested(V1ObjectMeta item) {
      this.builder = new V1ObjectMetaBuilder(this, item);
    }
    V1ObjectMetaBuilder builder;
    
    public N and() {
      return (N) V1RoleBindingFluent.this.withMetadata(builder.build());
    }
    
    public N endMetadata() {
      return and();
    }
    
  
  }
  public class RoleRefNested extends V1RoleRefFluent> implements Nested{
    RoleRefNested(V1RoleRef item) {
      this.builder = new V1RoleRefBuilder(this, item);
    }
    V1RoleRefBuilder builder;
    
    public N and() {
      return (N) V1RoleBindingFluent.this.withRoleRef(builder.build());
    }
    
    public N endRoleRef() {
      return and();
    }
    
  
  }
  public class SubjectsNested extends RbacV1SubjectFluent> implements Nested{
    SubjectsNested(int index,RbacV1Subject item) {
      this.index = index;
      this.builder = new RbacV1SubjectBuilder(this, item);
    }
    RbacV1SubjectBuilder builder;
    int index;
    
    public N and() {
      return (N) V1RoleBindingFluent.this.setToSubjects(index,builder.build());
    }
    
    public N endSubject() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy