io.kubernetes.client.openapi.models.V1alpha1ClusterRoleFluentImpl 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 V1alpha1ClusterRoleFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1alpha1ClusterRoleFluent {
private V1alpha1AggregationRuleBuilder aggregationRule;
private String apiVersion;
private String kind;
private V1ObjectMetaBuilder metadata;
private List rules;
public V1alpha1ClusterRoleFluentImpl() {
}
public V1alpha1ClusterRoleFluentImpl(V1alpha1ClusterRole instance) {
this.withAggregationRule(instance.getAggregationRule());
this.withApiVersion(instance.getApiVersion());
this.withKind(instance.getKind());
this.withMetadata(instance.getMetadata());
this.withRules(instance.getRules());
}
/**
* This method has been deprecated, please use method buildAggregationRule instead.
* @return The buildable object.
*/
@Deprecated public V1alpha1AggregationRule getAggregationRule() {
return this.aggregationRule!=null?this.aggregationRule.build():null;
}
public V1alpha1AggregationRule buildAggregationRule() {
return this.aggregationRule!=null?this.aggregationRule.build():null;
}
public A withAggregationRule(V1alpha1AggregationRule aggregationRule) {
_visitables.get("aggregationRule").remove(this.aggregationRule);
if (aggregationRule!=null){ this.aggregationRule= new V1alpha1AggregationRuleBuilder(aggregationRule); _visitables.get("aggregationRule").add(this.aggregationRule);} return (A) this;
}
public Boolean hasAggregationRule() {
return this.aggregationRule != null;
}
public V1alpha1ClusterRoleFluent.AggregationRuleNested withNewAggregationRule() {
return new AggregationRuleNestedImpl();
}
public V1alpha1ClusterRoleFluent.AggregationRuleNested withNewAggregationRuleLike(V1alpha1AggregationRule item) {
return new AggregationRuleNestedImpl(item);
}
public V1alpha1ClusterRoleFluent.AggregationRuleNested editAggregationRule() {
return withNewAggregationRuleLike(getAggregationRule());
}
public V1alpha1ClusterRoleFluent.AggregationRuleNested editOrNewAggregationRule() {
return withNewAggregationRuleLike(getAggregationRule() != null ? getAggregationRule(): new V1alpha1AggregationRuleBuilder().build());
}
public V1alpha1ClusterRoleFluent.AggregationRuleNested editOrNewAggregationRuleLike(V1alpha1AggregationRule item) {
return withNewAggregationRuleLike(getAggregationRule() != null ? getAggregationRule(): item);
}
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 V1alpha1ClusterRoleFluent.MetadataNested withNewMetadata() {
return new MetadataNestedImpl();
}
public V1alpha1ClusterRoleFluent.MetadataNested withNewMetadataLike(V1ObjectMeta item) {
return new MetadataNestedImpl(item);
}
public V1alpha1ClusterRoleFluent.MetadataNested editMetadata() {
return withNewMetadataLike(getMetadata());
}
public V1alpha1ClusterRoleFluent.MetadataNested editOrNewMetadata() {
return withNewMetadataLike(getMetadata() != null ? getMetadata(): new V1ObjectMetaBuilder().build());
}
public V1alpha1ClusterRoleFluent.MetadataNested editOrNewMetadataLike(V1ObjectMeta item) {
return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
}
public A addToRules(int index,V1alpha1PolicyRule item) {
if (this.rules == null) {this.rules = new ArrayList();}
V1alpha1PolicyRuleBuilder builder = new V1alpha1PolicyRuleBuilder(item);_visitables.get("rules").add(index >= 0 ? index : _visitables.get("rules").size(), builder);this.rules.add(index >= 0 ? index : rules.size(), builder); return (A)this;
}
public A setToRules(int index,V1alpha1PolicyRule item) {
if (this.rules == null) {this.rules = new ArrayList();}
V1alpha1PolicyRuleBuilder builder = new V1alpha1PolicyRuleBuilder(item);
if (index < 0 || index >= _visitables.get("rules").size()) { _visitables.get("rules").add(builder); } else { _visitables.get("rules").set(index, builder);}
if (index < 0 || index >= rules.size()) { rules.add(builder); } else { rules.set(index, builder);}
return (A)this;
}
public A addToRules(V1alpha1PolicyRule... items) {
if (this.rules == null) {this.rules = new ArrayList();}
for (V1alpha1PolicyRule item : items) {V1alpha1PolicyRuleBuilder builder = new V1alpha1PolicyRuleBuilder(item);_visitables.get("rules").add(builder);this.rules.add(builder);} return (A)this;
}
public A addAllToRules(Collection items) {
if (this.rules == null) {this.rules = new ArrayList();}
for (V1alpha1PolicyRule item : items) {V1alpha1PolicyRuleBuilder builder = new V1alpha1PolicyRuleBuilder(item);_visitables.get("rules").add(builder);this.rules.add(builder);} return (A)this;
}
public A removeFromRules(V1alpha1PolicyRule... items) {
for (V1alpha1PolicyRule item : items) {V1alpha1PolicyRuleBuilder builder = new V1alpha1PolicyRuleBuilder(item);_visitables.get("rules").remove(builder);if (this.rules != null) {this.rules.remove(builder);}} return (A)this;
}
public A removeAllFromRules(Collection items) {
for (V1alpha1PolicyRule item : items) {V1alpha1PolicyRuleBuilder builder = new V1alpha1PolicyRuleBuilder(item);_visitables.get("rules").remove(builder);if (this.rules != null) {this.rules.remove(builder);}} return (A)this;
}
public A removeMatchingFromRules(io.kubernetes.client.fluent.Predicate predicate) {
if (rules == null) return (A) this;
final Iterator each = rules.iterator();
final List visitables = _visitables.get("rules");
while (each.hasNext()) {
V1alpha1PolicyRuleBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildRules instead.
* @return The buildable object.
*/
@Deprecated public List getRules() {
return build(rules);
}
public List buildRules() {
return build(rules);
}
public V1alpha1PolicyRule buildRule(int index) {
return this.rules.get(index).build();
}
public V1alpha1PolicyRule buildFirstRule() {
return this.rules.get(0).build();
}
public V1alpha1PolicyRule buildLastRule() {
return this.rules.get(rules.size() - 1).build();
}
public V1alpha1PolicyRule buildMatchingRule(io.kubernetes.client.fluent.Predicate predicate) {
for (V1alpha1PolicyRuleBuilder item: rules) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingRule(io.kubernetes.client.fluent.Predicate predicate) {
for (V1alpha1PolicyRuleBuilder item: rules) { if(predicate.apply(item)){ return true;} } return false;
}
public A withRules(List rules) {
if (this.rules != null) { _visitables.get("rules").removeAll(this.rules);}
if (rules != null) {this.rules = new ArrayList(); for (V1alpha1PolicyRule item : rules){this.addToRules(item);}} else { this.rules = null;} return (A) this;
}
public A withRules(V1alpha1PolicyRule... rules) {
if (this.rules != null) {this.rules.clear();}
if (rules != null) {for (V1alpha1PolicyRule item :rules){ this.addToRules(item);}} return (A) this;
}
public Boolean hasRules() {
return rules != null && !rules.isEmpty();
}
public V1alpha1ClusterRoleFluent.RulesNested addNewRule() {
return new RulesNestedImpl();
}
public V1alpha1ClusterRoleFluent.RulesNested addNewRuleLike(V1alpha1PolicyRule item) {
return new RulesNestedImpl(-1, item);
}
public V1alpha1ClusterRoleFluent.RulesNested setNewRuleLike(int index,V1alpha1PolicyRule item) {
return new RulesNestedImpl(index, item);
}
public V1alpha1ClusterRoleFluent.RulesNested editRule(int index) {
if (rules.size() <= index) throw new RuntimeException("Can't edit rules. Index exceeds size.");
return setNewRuleLike(index, buildRule(index));
}
public V1alpha1ClusterRoleFluent.RulesNested editFirstRule() {
if (rules.size() == 0) throw new RuntimeException("Can't edit first rules. The list is empty.");
return setNewRuleLike(0, buildRule(0));
}
public V1alpha1ClusterRoleFluent.RulesNested editLastRule() {
int index = rules.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last rules. The list is empty.");
return setNewRuleLike(index, buildRule(index));
}
public V1alpha1ClusterRoleFluent.RulesNested editMatchingRule(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i extends V1alpha1AggregationRuleFluentImpl> implements V1alpha1ClusterRoleFluent.AggregationRuleNested,io.kubernetes.client.fluent.Nested {
private final V1alpha1AggregationRuleBuilder builder;
AggregationRuleNestedImpl(V1alpha1AggregationRule item) {
this.builder = new V1alpha1AggregationRuleBuilder(this, item);
}
AggregationRuleNestedImpl() {
this.builder = new V1alpha1AggregationRuleBuilder(this);
}
public N and() {
return (N) V1alpha1ClusterRoleFluentImpl.this.withAggregationRule(builder.build());
}
public N endAggregationRule() {
return and();
}
}
public class MetadataNestedImpl extends V1ObjectMetaFluentImpl> implements V1alpha1ClusterRoleFluent.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) V1alpha1ClusterRoleFluentImpl.this.withMetadata(builder.build());
}
public N endMetadata() {
return and();
}
}
public class RulesNestedImpl extends V1alpha1PolicyRuleFluentImpl> implements V1alpha1ClusterRoleFluent.RulesNested,io.kubernetes.client.fluent.Nested {
private final V1alpha1PolicyRuleBuilder builder;
private final int index;
RulesNestedImpl(int index,V1alpha1PolicyRule item) {
this.index = index;
this.builder = new V1alpha1PolicyRuleBuilder(this, item);
}
RulesNestedImpl() {
this.index = -1;
this.builder = new V1alpha1PolicyRuleBuilder(this);
}
public N and() {
return (N) V1alpha1ClusterRoleFluentImpl.this.setToRules(index,builder.build());
}
public N endRule() {
return and();
}
}
}