io.kubernetes.client.openapi.models.V1NetworkPolicySpecFluentImpl 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 V1NetworkPolicySpecFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1NetworkPolicySpecFluent {
private List egress;
private List ingress;
private V1LabelSelectorBuilder podSelector;
private List policyTypes;
public V1NetworkPolicySpecFluentImpl() {
}
public V1NetworkPolicySpecFluentImpl(V1NetworkPolicySpec instance) {
this.withEgress(instance.getEgress());
this.withIngress(instance.getIngress());
this.withPodSelector(instance.getPodSelector());
this.withPolicyTypes(instance.getPolicyTypes());
}
public A addToEgress(int index,V1NetworkPolicyEgressRule item) {
if (this.egress == null) {this.egress = new ArrayList();}
V1NetworkPolicyEgressRuleBuilder builder = new V1NetworkPolicyEgressRuleBuilder(item);_visitables.get("egress").add(index >= 0 ? index : _visitables.get("egress").size(), builder);this.egress.add(index >= 0 ? index : egress.size(), builder); return (A)this;
}
public A setToEgress(int index,V1NetworkPolicyEgressRule item) {
if (this.egress == null) {this.egress = new ArrayList();}
V1NetworkPolicyEgressRuleBuilder builder = new V1NetworkPolicyEgressRuleBuilder(item);
if (index < 0 || index >= _visitables.get("egress").size()) { _visitables.get("egress").add(builder); } else { _visitables.get("egress").set(index, builder);}
if (index < 0 || index >= egress.size()) { egress.add(builder); } else { egress.set(index, builder);}
return (A)this;
}
public A addToEgress(V1NetworkPolicyEgressRule... items) {
if (this.egress == null) {this.egress = new ArrayList();}
for (V1NetworkPolicyEgressRule item : items) {V1NetworkPolicyEgressRuleBuilder builder = new V1NetworkPolicyEgressRuleBuilder(item);_visitables.get("egress").add(builder);this.egress.add(builder);} return (A)this;
}
public A addAllToEgress(Collection items) {
if (this.egress == null) {this.egress = new ArrayList();}
for (V1NetworkPolicyEgressRule item : items) {V1NetworkPolicyEgressRuleBuilder builder = new V1NetworkPolicyEgressRuleBuilder(item);_visitables.get("egress").add(builder);this.egress.add(builder);} return (A)this;
}
public A removeFromEgress(V1NetworkPolicyEgressRule... items) {
for (V1NetworkPolicyEgressRule item : items) {V1NetworkPolicyEgressRuleBuilder builder = new V1NetworkPolicyEgressRuleBuilder(item);_visitables.get("egress").remove(builder);if (this.egress != null) {this.egress.remove(builder);}} return (A)this;
}
public A removeAllFromEgress(Collection items) {
for (V1NetworkPolicyEgressRule item : items) {V1NetworkPolicyEgressRuleBuilder builder = new V1NetworkPolicyEgressRuleBuilder(item);_visitables.get("egress").remove(builder);if (this.egress != null) {this.egress.remove(builder);}} return (A)this;
}
public A removeMatchingFromEgress(io.kubernetes.client.fluent.Predicate predicate) {
if (egress == null) return (A) this;
final Iterator each = egress.iterator();
final List visitables = _visitables.get("egress");
while (each.hasNext()) {
V1NetworkPolicyEgressRuleBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildEgress instead.
* @return The buildable object.
*/
@Deprecated public List getEgress() {
return build(egress);
}
public List buildEgress() {
return build(egress);
}
public V1NetworkPolicyEgressRule buildEgress(int index) {
return this.egress.get(index).build();
}
public V1NetworkPolicyEgressRule buildFirstEgress() {
return this.egress.get(0).build();
}
public V1NetworkPolicyEgressRule buildLastEgress() {
return this.egress.get(egress.size() - 1).build();
}
public V1NetworkPolicyEgressRule buildMatchingEgress(io.kubernetes.client.fluent.Predicate predicate) {
for (V1NetworkPolicyEgressRuleBuilder item: egress) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingEgress(io.kubernetes.client.fluent.Predicate predicate) {
for (V1NetworkPolicyEgressRuleBuilder item: egress) { if(predicate.apply(item)){ return true;} } return false;
}
public A withEgress(List egress) {
if (this.egress != null) { _visitables.get("egress").removeAll(this.egress);}
if (egress != null) {this.egress = new ArrayList(); for (V1NetworkPolicyEgressRule item : egress){this.addToEgress(item);}} else { this.egress = null;} return (A) this;
}
public A withEgress(V1NetworkPolicyEgressRule... egress) {
if (this.egress != null) {this.egress.clear();}
if (egress != null) {for (V1NetworkPolicyEgressRule item :egress){ this.addToEgress(item);}} return (A) this;
}
public Boolean hasEgress() {
return egress != null && !egress.isEmpty();
}
public V1NetworkPolicySpecFluent.EgressNested addNewEgress() {
return new EgressNestedImpl();
}
public V1NetworkPolicySpecFluent.EgressNested addNewEgressLike(V1NetworkPolicyEgressRule item) {
return new EgressNestedImpl(-1, item);
}
public V1NetworkPolicySpecFluent.EgressNested setNewEgressLike(int index,V1NetworkPolicyEgressRule item) {
return new EgressNestedImpl(index, item);
}
public V1NetworkPolicySpecFluent.EgressNested editEgress(int index) {
if (egress.size() <= index) throw new RuntimeException("Can't edit egress. Index exceeds size.");
return setNewEgressLike(index, buildEgress(index));
}
public V1NetworkPolicySpecFluent.EgressNested editFirstEgress() {
if (egress.size() == 0) throw new RuntimeException("Can't edit first egress. The list is empty.");
return setNewEgressLike(0, buildEgress(0));
}
public V1NetworkPolicySpecFluent.EgressNested editLastEgress() {
int index = egress.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last egress. The list is empty.");
return setNewEgressLike(index, buildEgress(index));
}
public V1NetworkPolicySpecFluent.EgressNested editMatchingEgress(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i();}
V1NetworkPolicyIngressRuleBuilder builder = new V1NetworkPolicyIngressRuleBuilder(item);_visitables.get("ingress").add(index >= 0 ? index : _visitables.get("ingress").size(), builder);this.ingress.add(index >= 0 ? index : ingress.size(), builder); return (A)this;
}
public A setToIngress(int index,V1NetworkPolicyIngressRule item) {
if (this.ingress == null) {this.ingress = new ArrayList();}
V1NetworkPolicyIngressRuleBuilder builder = new V1NetworkPolicyIngressRuleBuilder(item);
if (index < 0 || index >= _visitables.get("ingress").size()) { _visitables.get("ingress").add(builder); } else { _visitables.get("ingress").set(index, builder);}
if (index < 0 || index >= ingress.size()) { ingress.add(builder); } else { ingress.set(index, builder);}
return (A)this;
}
public A addToIngress(V1NetworkPolicyIngressRule... items) {
if (this.ingress == null) {this.ingress = new ArrayList();}
for (V1NetworkPolicyIngressRule item : items) {V1NetworkPolicyIngressRuleBuilder builder = new V1NetworkPolicyIngressRuleBuilder(item);_visitables.get("ingress").add(builder);this.ingress.add(builder);} return (A)this;
}
public A addAllToIngress(Collection items) {
if (this.ingress == null) {this.ingress = new ArrayList();}
for (V1NetworkPolicyIngressRule item : items) {V1NetworkPolicyIngressRuleBuilder builder = new V1NetworkPolicyIngressRuleBuilder(item);_visitables.get("ingress").add(builder);this.ingress.add(builder);} return (A)this;
}
public A removeFromIngress(V1NetworkPolicyIngressRule... items) {
for (V1NetworkPolicyIngressRule item : items) {V1NetworkPolicyIngressRuleBuilder builder = new V1NetworkPolicyIngressRuleBuilder(item);_visitables.get("ingress").remove(builder);if (this.ingress != null) {this.ingress.remove(builder);}} return (A)this;
}
public A removeAllFromIngress(Collection items) {
for (V1NetworkPolicyIngressRule item : items) {V1NetworkPolicyIngressRuleBuilder builder = new V1NetworkPolicyIngressRuleBuilder(item);_visitables.get("ingress").remove(builder);if (this.ingress != null) {this.ingress.remove(builder);}} return (A)this;
}
public A removeMatchingFromIngress(io.kubernetes.client.fluent.Predicate predicate) {
if (ingress == null) return (A) this;
final Iterator each = ingress.iterator();
final List visitables = _visitables.get("ingress");
while (each.hasNext()) {
V1NetworkPolicyIngressRuleBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildIngress instead.
* @return The buildable object.
*/
@Deprecated public List getIngress() {
return build(ingress);
}
public List buildIngress() {
return build(ingress);
}
public V1NetworkPolicyIngressRule buildIngress(int index) {
return this.ingress.get(index).build();
}
public V1NetworkPolicyIngressRule buildFirstIngress() {
return this.ingress.get(0).build();
}
public V1NetworkPolicyIngressRule buildLastIngress() {
return this.ingress.get(ingress.size() - 1).build();
}
public V1NetworkPolicyIngressRule buildMatchingIngress(io.kubernetes.client.fluent.Predicate predicate) {
for (V1NetworkPolicyIngressRuleBuilder item: ingress) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingIngress(io.kubernetes.client.fluent.Predicate predicate) {
for (V1NetworkPolicyIngressRuleBuilder item: ingress) { if(predicate.apply(item)){ return true;} } return false;
}
public A withIngress(List ingress) {
if (this.ingress != null) { _visitables.get("ingress").removeAll(this.ingress);}
if (ingress != null) {this.ingress = new ArrayList(); for (V1NetworkPolicyIngressRule item : ingress){this.addToIngress(item);}} else { this.ingress = null;} return (A) this;
}
public A withIngress(V1NetworkPolicyIngressRule... ingress) {
if (this.ingress != null) {this.ingress.clear();}
if (ingress != null) {for (V1NetworkPolicyIngressRule item :ingress){ this.addToIngress(item);}} return (A) this;
}
public Boolean hasIngress() {
return ingress != null && !ingress.isEmpty();
}
public V1NetworkPolicySpecFluent.IngressNested addNewIngress() {
return new IngressNestedImpl();
}
public V1NetworkPolicySpecFluent.IngressNested addNewIngressLike(V1NetworkPolicyIngressRule item) {
return new IngressNestedImpl(-1, item);
}
public V1NetworkPolicySpecFluent.IngressNested setNewIngressLike(int index,V1NetworkPolicyIngressRule item) {
return new IngressNestedImpl(index, item);
}
public V1NetworkPolicySpecFluent.IngressNested editIngress(int index) {
if (ingress.size() <= index) throw new RuntimeException("Can't edit ingress. Index exceeds size.");
return setNewIngressLike(index, buildIngress(index));
}
public V1NetworkPolicySpecFluent.IngressNested editFirstIngress() {
if (ingress.size() == 0) throw new RuntimeException("Can't edit first ingress. The list is empty.");
return setNewIngressLike(0, buildIngress(0));
}
public V1NetworkPolicySpecFluent.IngressNested editLastIngress() {
int index = ingress.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last ingress. The list is empty.");
return setNewIngressLike(index, buildIngress(index));
}
public V1NetworkPolicySpecFluent.IngressNested editMatchingIngress(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i withNewPodSelector() {
return new PodSelectorNestedImpl();
}
public V1NetworkPolicySpecFluent.PodSelectorNested withNewPodSelectorLike(V1LabelSelector item) {
return new PodSelectorNestedImpl(item);
}
public V1NetworkPolicySpecFluent.PodSelectorNested editPodSelector() {
return withNewPodSelectorLike(getPodSelector());
}
public V1NetworkPolicySpecFluent.PodSelectorNested editOrNewPodSelector() {
return withNewPodSelectorLike(getPodSelector() != null ? getPodSelector(): new V1LabelSelectorBuilder().build());
}
public V1NetworkPolicySpecFluent.PodSelectorNested editOrNewPodSelectorLike(V1LabelSelector item) {
return withNewPodSelectorLike(getPodSelector() != null ? getPodSelector(): item);
}
public A addToPolicyTypes(int index,String item) {
if (this.policyTypes == null) {this.policyTypes = new ArrayList();}
this.policyTypes.add(index, item);
return (A)this;
}
public A setToPolicyTypes(int index,String item) {
if (this.policyTypes == null) {this.policyTypes = new ArrayList();}
this.policyTypes.set(index, item); return (A)this;
}
public A addToPolicyTypes(String... items) {
if (this.policyTypes == null) {this.policyTypes = new ArrayList();}
for (String item : items) {this.policyTypes.add(item);} return (A)this;
}
public A addAllToPolicyTypes(Collection items) {
if (this.policyTypes == null) {this.policyTypes = new ArrayList();}
for (String item : items) {this.policyTypes.add(item);} return (A)this;
}
public A removeFromPolicyTypes(String... items) {
for (String item : items) {if (this.policyTypes!= null){ this.policyTypes.remove(item);}} return (A)this;
}
public A removeAllFromPolicyTypes(Collection items) {
for (String item : items) {if (this.policyTypes!= null){ this.policyTypes.remove(item);}} return (A)this;
}
public List getPolicyTypes() {
return this.policyTypes;
}
public String getPolicyType(int index) {
return this.policyTypes.get(index);
}
public String getFirstPolicyType() {
return this.policyTypes.get(0);
}
public String getLastPolicyType() {
return this.policyTypes.get(policyTypes.size() - 1);
}
public String getMatchingPolicyType(io.kubernetes.client.fluent.Predicate predicate) {
for (String item: policyTypes) { if(predicate.apply(item)){ return item;} } return null;
}
public Boolean hasMatchingPolicyType(io.kubernetes.client.fluent.Predicate predicate) {
for (String item: policyTypes) { if(predicate.apply(item)){ return true;} } return false;
}
public A withPolicyTypes(List policyTypes) {
if (this.policyTypes != null) { _visitables.get("policyTypes").removeAll(this.policyTypes);}
if (policyTypes != null) {this.policyTypes = new ArrayList(); for (String item : policyTypes){this.addToPolicyTypes(item);}} else { this.policyTypes = null;} return (A) this;
}
public A withPolicyTypes(String... policyTypes) {
if (this.policyTypes != null) {this.policyTypes.clear();}
if (policyTypes != null) {for (String item :policyTypes){ this.addToPolicyTypes(item);}} return (A) this;
}
public Boolean hasPolicyTypes() {
return policyTypes != null && !policyTypes.isEmpty();
}
public A addNewPolicyType(String arg1) {
return (A)addToPolicyTypes(new String(arg1));
}
public A addNewPolicyType(StringBuilder arg1) {
return (A)addToPolicyTypes(new String(arg1));
}
public A addNewPolicyType(StringBuffer arg1) {
return (A)addToPolicyTypes(new String(arg1));
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
V1NetworkPolicySpecFluentImpl that = (V1NetworkPolicySpecFluentImpl) o;
if (egress != null ? !egress.equals(that.egress) :that.egress != null) return false;
if (ingress != null ? !ingress.equals(that.ingress) :that.ingress != null) return false;
if (podSelector != null ? !podSelector.equals(that.podSelector) :that.podSelector != null) return false;
if (policyTypes != null ? !policyTypes.equals(that.policyTypes) :that.policyTypes != null) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(egress, ingress, podSelector, policyTypes, super.hashCode());
}
public class EgressNestedImpl extends V1NetworkPolicyEgressRuleFluentImpl> implements V1NetworkPolicySpecFluent.EgressNested,io.kubernetes.client.fluent.Nested {
private final V1NetworkPolicyEgressRuleBuilder builder;
private final int index;
EgressNestedImpl(int index,V1NetworkPolicyEgressRule item) {
this.index = index;
this.builder = new V1NetworkPolicyEgressRuleBuilder(this, item);
}
EgressNestedImpl() {
this.index = -1;
this.builder = new V1NetworkPolicyEgressRuleBuilder(this);
}
public N and() {
return (N) V1NetworkPolicySpecFluentImpl.this.setToEgress(index,builder.build());
}
public N endEgress() {
return and();
}
}
public class IngressNestedImpl extends V1NetworkPolicyIngressRuleFluentImpl> implements V1NetworkPolicySpecFluent.IngressNested,io.kubernetes.client.fluent.Nested {
private final V1NetworkPolicyIngressRuleBuilder builder;
private final int index;
IngressNestedImpl(int index,V1NetworkPolicyIngressRule item) {
this.index = index;
this.builder = new V1NetworkPolicyIngressRuleBuilder(this, item);
}
IngressNestedImpl() {
this.index = -1;
this.builder = new V1NetworkPolicyIngressRuleBuilder(this);
}
public N and() {
return (N) V1NetworkPolicySpecFluentImpl.this.setToIngress(index,builder.build());
}
public N endIngress() {
return and();
}
}
public class PodSelectorNestedImpl extends V1LabelSelectorFluentImpl> implements V1NetworkPolicySpecFluent.PodSelectorNested,io.kubernetes.client.fluent.Nested {
private final V1LabelSelectorBuilder builder;
PodSelectorNestedImpl(V1LabelSelector item) {
this.builder = new V1LabelSelectorBuilder(this, item);
}
PodSelectorNestedImpl() {
this.builder = new V1LabelSelectorBuilder(this);
}
public N and() {
return (N) V1NetworkPolicySpecFluentImpl.this.withPodSelector(builder.build());
}
public N endPodSelector() {
return and();
}
}
}