io.kubernetes.client.openapi.models.V1beta1ClusterRoleBindingFluentImpl Maven / Gradle / Ivy
package io.kubernetes.client.openapi.models;
import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.StringBuilder;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.kubernetes.client.fluent.Predicate;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.StringBuffer;
import java.util.Collection;
import java.lang.Object;
public class V1beta1ClusterRoleBindingFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1beta1ClusterRoleBindingFluent {
private String apiVersion;
private String kind;
private V1ObjectMetaBuilder metadata;
private V1beta1RoleRefBuilder roleRef;
private List subjects;
public V1beta1ClusterRoleBindingFluentImpl() {
}
public V1beta1ClusterRoleBindingFluentImpl(V1beta1ClusterRoleBinding instance) {
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 A withNewApiVersion(String arg1) {
return (A)withApiVersion(new String(arg1));
}
public A withNewApiVersion(StringBuilder arg1) {
return (A)withApiVersion(new String(arg1));
}
public A withNewApiVersion(StringBuffer arg1) {
return (A)withApiVersion(new String(arg1));
}
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 A withNewKind(String arg1) {
return (A)withKind(new String(arg1));
}
public A withNewKind(StringBuilder arg1) {
return (A)withKind(new String(arg1));
}
public A withNewKind(StringBuffer arg1) {
return (A)withKind(new String(arg1));
}
/**
* This method has been deprecated, please use method buildMetadata instead.
* @return The buildable object.
*/
@Deprecated public V1ObjectMeta getMetadata() {
return this.metadata!=null?this.metadata.build():null;
}
public V1ObjectMeta buildMetadata() {
return this.metadata!=null?this.metadata.build():null;
}
public A withMetadata(V1ObjectMeta metadata) {
_visitables.get("metadata").remove(this.metadata);
if (metadata!=null){ this.metadata= new V1ObjectMetaBuilder(metadata); _visitables.get("metadata").add(this.metadata);} return (A) this;
}
public Boolean hasMetadata() {
return this.metadata != null;
}
public V1beta1ClusterRoleBindingFluent.MetadataNested withNewMetadata() {
return new MetadataNestedImpl();
}
public V1beta1ClusterRoleBindingFluent.MetadataNested withNewMetadataLike(V1ObjectMeta item) {
return new MetadataNestedImpl(item);
}
public V1beta1ClusterRoleBindingFluent.MetadataNested editMetadata() {
return withNewMetadataLike(getMetadata());
}
public V1beta1ClusterRoleBindingFluent.MetadataNested editOrNewMetadata() {
return withNewMetadataLike(getMetadata() != null ? getMetadata(): new V1ObjectMetaBuilder().build());
}
public V1beta1ClusterRoleBindingFluent.MetadataNested editOrNewMetadataLike(V1ObjectMeta item) {
return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
}
/**
* This method has been deprecated, please use method buildRoleRef instead.
* @return The buildable object.
*/
@Deprecated public V1beta1RoleRef getRoleRef() {
return this.roleRef!=null?this.roleRef.build():null;
}
public V1beta1RoleRef buildRoleRef() {
return this.roleRef!=null?this.roleRef.build():null;
}
public A withRoleRef(V1beta1RoleRef roleRef) {
_visitables.get("roleRef").remove(this.roleRef);
if (roleRef!=null){ this.roleRef= new V1beta1RoleRefBuilder(roleRef); _visitables.get("roleRef").add(this.roleRef);} return (A) this;
}
public Boolean hasRoleRef() {
return this.roleRef != null;
}
public V1beta1ClusterRoleBindingFluent.RoleRefNested withNewRoleRef() {
return new RoleRefNestedImpl();
}
public V1beta1ClusterRoleBindingFluent.RoleRefNested withNewRoleRefLike(V1beta1RoleRef item) {
return new RoleRefNestedImpl(item);
}
public V1beta1ClusterRoleBindingFluent.RoleRefNested editRoleRef() {
return withNewRoleRefLike(getRoleRef());
}
public V1beta1ClusterRoleBindingFluent.RoleRefNested editOrNewRoleRef() {
return withNewRoleRefLike(getRoleRef() != null ? getRoleRef(): new V1beta1RoleRefBuilder().build());
}
public V1beta1ClusterRoleBindingFluent.RoleRefNested editOrNewRoleRefLike(V1beta1RoleRef item) {
return withNewRoleRefLike(getRoleRef() != null ? getRoleRef(): item);
}
public A addToSubjects(int index,RbacV1beta1Subject item) {
if (this.subjects == null) {this.subjects = new ArrayList();}
RbacV1beta1SubjectBuilder builder = new RbacV1beta1SubjectBuilder(item);_visitables.get("subjects").add(index >= 0 ? index : _visitables.get("subjects").size(), builder);this.subjects.add(index >= 0 ? index : subjects.size(), builder); return (A)this;
}
public A setToSubjects(int index,RbacV1beta1Subject item) {
if (this.subjects == null) {this.subjects = new ArrayList();}
RbacV1beta1SubjectBuilder builder = new RbacV1beta1SubjectBuilder(item);
if (index < 0 || index >= _visitables.get("subjects").size()) { _visitables.get("subjects").add(builder); } else { _visitables.get("subjects").set(index, builder);}
if (index < 0 || index >= subjects.size()) { subjects.add(builder); } else { subjects.set(index, builder);}
return (A)this;
}
public A addToSubjects(RbacV1beta1Subject... items) {
if (this.subjects == null) {this.subjects = new ArrayList();}
for (RbacV1beta1Subject item : items) {RbacV1beta1SubjectBuilder builder = new RbacV1beta1SubjectBuilder(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 (RbacV1beta1Subject item : items) {RbacV1beta1SubjectBuilder builder = new RbacV1beta1SubjectBuilder(item);_visitables.get("subjects").add(builder);this.subjects.add(builder);} return (A)this;
}
public A removeFromSubjects(RbacV1beta1Subject... items) {
for (RbacV1beta1Subject item : items) {RbacV1beta1SubjectBuilder builder = new RbacV1beta1SubjectBuilder(item);_visitables.get("subjects").remove(builder);if (this.subjects != null) {this.subjects.remove(builder);}} return (A)this;
}
public A removeAllFromSubjects(Collection items) {
for (RbacV1beta1Subject item : items) {RbacV1beta1SubjectBuilder builder = new RbacV1beta1SubjectBuilder(item);_visitables.get("subjects").remove(builder);if (this.subjects != null) {this.subjects.remove(builder);}} return (A)this;
}
public A removeMatchingFromSubjects(io.kubernetes.client.fluent.Predicate predicate) {
if (subjects == null) return (A) this;
final Iterator each = subjects.iterator();
final List visitables = _visitables.get("subjects");
while (each.hasNext()) {
RbacV1beta1SubjectBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildSubjects instead.
* @return The buildable object.
*/
@Deprecated public List getSubjects() {
return build(subjects);
}
public List buildSubjects() {
return build(subjects);
}
public RbacV1beta1Subject buildSubject(int index) {
return this.subjects.get(index).build();
}
public RbacV1beta1Subject buildFirstSubject() {
return this.subjects.get(0).build();
}
public RbacV1beta1Subject buildLastSubject() {
return this.subjects.get(subjects.size() - 1).build();
}
public RbacV1beta1Subject buildMatchingSubject(io.kubernetes.client.fluent.Predicate predicate) {
for (RbacV1beta1SubjectBuilder item: subjects) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingSubject(io.kubernetes.client.fluent.Predicate predicate) {
for (RbacV1beta1SubjectBuilder item: subjects) { if(predicate.apply(item)){ return true;} } return false;
}
public A withSubjects(List subjects) {
if (this.subjects != null) { _visitables.get("subjects").removeAll(this.subjects);}
if (subjects != null) {this.subjects = new ArrayList(); for (RbacV1beta1Subject item : subjects){this.addToSubjects(item);}} else { this.subjects = null;} return (A) this;
}
public A withSubjects(RbacV1beta1Subject... subjects) {
if (this.subjects != null) {this.subjects.clear();}
if (subjects != null) {for (RbacV1beta1Subject item :subjects){ this.addToSubjects(item);}} return (A) this;
}
public Boolean hasSubjects() {
return subjects != null && !subjects.isEmpty();
}
public V1beta1ClusterRoleBindingFluent.SubjectsNested addNewSubject() {
return new SubjectsNestedImpl();
}
public V1beta1ClusterRoleBindingFluent.SubjectsNested addNewSubjectLike(RbacV1beta1Subject item) {
return new SubjectsNestedImpl(-1, item);
}
public V1beta1ClusterRoleBindingFluent.SubjectsNested setNewSubjectLike(int index,RbacV1beta1Subject item) {
return new SubjectsNestedImpl(index, item);
}
public V1beta1ClusterRoleBindingFluent.SubjectsNested editSubject(int index) {
if (subjects.size() <= index) throw new RuntimeException("Can't edit subjects. Index exceeds size.");
return setNewSubjectLike(index, buildSubject(index));
}
public V1beta1ClusterRoleBindingFluent.SubjectsNested editFirstSubject() {
if (subjects.size() == 0) throw new RuntimeException("Can't edit first subjects. The list is empty.");
return setNewSubjectLike(0, buildSubject(0));
}
public V1beta1ClusterRoleBindingFluent.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 V1beta1ClusterRoleBindingFluent.SubjectsNested editMatchingSubject(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i extends V1ObjectMetaFluentImpl> implements V1beta1ClusterRoleBindingFluent.MetadataNested,io.kubernetes.client.fluent.Nested {
private final V1ObjectMetaBuilder builder;
MetadataNestedImpl(V1ObjectMeta item) {
this.builder = new V1ObjectMetaBuilder(this, item);
}
MetadataNestedImpl() {
this.builder = new V1ObjectMetaBuilder(this);
}
public N and() {
return (N) V1beta1ClusterRoleBindingFluentImpl.this.withMetadata(builder.build());
}
public N endMetadata() {
return and();
}
}
public class RoleRefNestedImpl extends V1beta1RoleRefFluentImpl> implements V1beta1ClusterRoleBindingFluent.RoleRefNested,io.kubernetes.client.fluent.Nested {
private final V1beta1RoleRefBuilder builder;
RoleRefNestedImpl(V1beta1RoleRef item) {
this.builder = new V1beta1RoleRefBuilder(this, item);
}
RoleRefNestedImpl() {
this.builder = new V1beta1RoleRefBuilder(this);
}
public N and() {
return (N) V1beta1ClusterRoleBindingFluentImpl.this.withRoleRef(builder.build());
}
public N endRoleRef() {
return and();
}
}
public class SubjectsNestedImpl extends RbacV1beta1SubjectFluentImpl> implements V1beta1ClusterRoleBindingFluent.SubjectsNested,io.kubernetes.client.fluent.Nested {
private final RbacV1beta1SubjectBuilder builder;
private final int index;
SubjectsNestedImpl(int index,RbacV1beta1Subject item) {
this.index = index;
this.builder = new RbacV1beta1SubjectBuilder(this, item);
}
SubjectsNestedImpl() {
this.index = -1;
this.builder = new RbacV1beta1SubjectBuilder(this);
}
public N and() {
return (N) V1beta1ClusterRoleBindingFluentImpl.this.setToSubjects(index,builder.build());
}
public N endSubject() {
return and();
}
}
}