io.kubernetes.client.openapi.models.V1NodeAffinityFluentImpl Maven / Gradle / Ivy
package io.kubernetes.client.openapi.models;
import io.kubernetes.client.fluent.VisitableBuilder;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
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.util.Collection;
import java.lang.Object;
public class V1NodeAffinityFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1NodeAffinityFluent {
private List preferredDuringSchedulingIgnoredDuringExecution;
private V1NodeSelectorBuilder requiredDuringSchedulingIgnoredDuringExecution;
public V1NodeAffinityFluentImpl() {
}
public V1NodeAffinityFluentImpl(V1NodeAffinity instance) {
this.withPreferredDuringSchedulingIgnoredDuringExecution(instance.getPreferredDuringSchedulingIgnoredDuringExecution());
this.withRequiredDuringSchedulingIgnoredDuringExecution(instance.getRequiredDuringSchedulingIgnoredDuringExecution());
}
public A addToPreferredDuringSchedulingIgnoredDuringExecution(int index,V1PreferredSchedulingTerm item) {
if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
V1PreferredSchedulingTermBuilder builder = new V1PreferredSchedulingTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(index >= 0 ? index : _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").size(), builder);this.preferredDuringSchedulingIgnoredDuringExecution.add(index >= 0 ? index : preferredDuringSchedulingIgnoredDuringExecution.size(), builder); return (A)this;
}
public A setToPreferredDuringSchedulingIgnoredDuringExecution(int index,V1PreferredSchedulingTerm item) {
if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
V1PreferredSchedulingTermBuilder builder = new V1PreferredSchedulingTermBuilder(item);
if (index < 0 || index >= _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").size()) { _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(builder); } else { _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").set(index, builder);}
if (index < 0 || index >= preferredDuringSchedulingIgnoredDuringExecution.size()) { preferredDuringSchedulingIgnoredDuringExecution.add(builder); } else { preferredDuringSchedulingIgnoredDuringExecution.set(index, builder);}
return (A)this;
}
public A addToPreferredDuringSchedulingIgnoredDuringExecution(V1PreferredSchedulingTerm... items) {
if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
for (V1PreferredSchedulingTerm item : items) {V1PreferredSchedulingTermBuilder builder = new V1PreferredSchedulingTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(builder);this.preferredDuringSchedulingIgnoredDuringExecution.add(builder);} return (A)this;
}
public A addAllToPreferredDuringSchedulingIgnoredDuringExecution(Collection items) {
if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
for (V1PreferredSchedulingTerm item : items) {V1PreferredSchedulingTermBuilder builder = new V1PreferredSchedulingTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(builder);this.preferredDuringSchedulingIgnoredDuringExecution.add(builder);} return (A)this;
}
public A removeFromPreferredDuringSchedulingIgnoredDuringExecution(V1PreferredSchedulingTerm... items) {
for (V1PreferredSchedulingTerm item : items) {V1PreferredSchedulingTermBuilder builder = new V1PreferredSchedulingTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").remove(builder);if (this.preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution.remove(builder);}} return (A)this;
}
public A removeAllFromPreferredDuringSchedulingIgnoredDuringExecution(Collection items) {
for (V1PreferredSchedulingTerm item : items) {V1PreferredSchedulingTermBuilder builder = new V1PreferredSchedulingTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").remove(builder);if (this.preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution.remove(builder);}} return (A)this;
}
public A removeMatchingFromPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
if (preferredDuringSchedulingIgnoredDuringExecution == null) return (A) this;
final Iterator each = preferredDuringSchedulingIgnoredDuringExecution.iterator();
final List visitables = _visitables.get("preferredDuringSchedulingIgnoredDuringExecution");
while (each.hasNext()) {
V1PreferredSchedulingTermBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildPreferredDuringSchedulingIgnoredDuringExecution instead.
* @return The buildable object.
*/
@Deprecated public List getPreferredDuringSchedulingIgnoredDuringExecution() {
return build(preferredDuringSchedulingIgnoredDuringExecution);
}
public List buildPreferredDuringSchedulingIgnoredDuringExecution() {
return build(preferredDuringSchedulingIgnoredDuringExecution);
}
public V1PreferredSchedulingTerm buildPreferredDuringSchedulingIgnoredDuringExecution(int index) {
return this.preferredDuringSchedulingIgnoredDuringExecution.get(index).build();
}
public V1PreferredSchedulingTerm buildFirstPreferredDuringSchedulingIgnoredDuringExecution() {
return this.preferredDuringSchedulingIgnoredDuringExecution.get(0).build();
}
public V1PreferredSchedulingTerm buildLastPreferredDuringSchedulingIgnoredDuringExecution() {
return this.preferredDuringSchedulingIgnoredDuringExecution.get(preferredDuringSchedulingIgnoredDuringExecution.size() - 1).build();
}
public V1PreferredSchedulingTerm buildMatchingPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
for (V1PreferredSchedulingTermBuilder item: preferredDuringSchedulingIgnoredDuringExecution) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
for (V1PreferredSchedulingTermBuilder item: preferredDuringSchedulingIgnoredDuringExecution) { if(predicate.apply(item)){ return true;} } return false;
}
public A withPreferredDuringSchedulingIgnoredDuringExecution(List preferredDuringSchedulingIgnoredDuringExecution) {
if (this.preferredDuringSchedulingIgnoredDuringExecution != null) { _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").removeAll(this.preferredDuringSchedulingIgnoredDuringExecution);}
if (preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList(); for (V1PreferredSchedulingTerm item : preferredDuringSchedulingIgnoredDuringExecution){this.addToPreferredDuringSchedulingIgnoredDuringExecution(item);}} else { this.preferredDuringSchedulingIgnoredDuringExecution = null;} return (A) this;
}
public A withPreferredDuringSchedulingIgnoredDuringExecution(V1PreferredSchedulingTerm... preferredDuringSchedulingIgnoredDuringExecution) {
if (this.preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution.clear();}
if (preferredDuringSchedulingIgnoredDuringExecution != null) {for (V1PreferredSchedulingTerm item :preferredDuringSchedulingIgnoredDuringExecution){ this.addToPreferredDuringSchedulingIgnoredDuringExecution(item);}} return (A) this;
}
public Boolean hasPreferredDuringSchedulingIgnoredDuringExecution() {
return preferredDuringSchedulingIgnoredDuringExecution != null && !preferredDuringSchedulingIgnoredDuringExecution.isEmpty();
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested addNewPreferredDuringSchedulingIgnoredDuringExecution() {
return new PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl();
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested addNewPreferredDuringSchedulingIgnoredDuringExecutionLike(V1PreferredSchedulingTerm item) {
return new PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl(-1, item);
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(int index,V1PreferredSchedulingTerm item) {
return new PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl(index, item);
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editPreferredDuringSchedulingIgnoredDuringExecution(int index) {
if (preferredDuringSchedulingIgnoredDuringExecution.size() <= index) throw new RuntimeException("Can't edit preferredDuringSchedulingIgnoredDuringExecution. Index exceeds size.");
return setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(index, buildPreferredDuringSchedulingIgnoredDuringExecution(index));
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editFirstPreferredDuringSchedulingIgnoredDuringExecution() {
if (preferredDuringSchedulingIgnoredDuringExecution.size() == 0) throw new RuntimeException("Can't edit first preferredDuringSchedulingIgnoredDuringExecution. The list is empty.");
return setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(0, buildPreferredDuringSchedulingIgnoredDuringExecution(0));
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editLastPreferredDuringSchedulingIgnoredDuringExecution() {
int index = preferredDuringSchedulingIgnoredDuringExecution.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last preferredDuringSchedulingIgnoredDuringExecution. The list is empty.");
return setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(index, buildPreferredDuringSchedulingIgnoredDuringExecution(index));
}
public V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editMatchingPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i withNewRequiredDuringSchedulingIgnoredDuringExecution() {
return new RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl();
}
public V1NodeAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested withNewRequiredDuringSchedulingIgnoredDuringExecutionLike(V1NodeSelector item) {
return new RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl(item);
}
public V1NodeAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editRequiredDuringSchedulingIgnoredDuringExecution() {
return withNewRequiredDuringSchedulingIgnoredDuringExecutionLike(getRequiredDuringSchedulingIgnoredDuringExecution());
}
public V1NodeAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editOrNewRequiredDuringSchedulingIgnoredDuringExecution() {
return withNewRequiredDuringSchedulingIgnoredDuringExecutionLike(getRequiredDuringSchedulingIgnoredDuringExecution() != null ? getRequiredDuringSchedulingIgnoredDuringExecution(): new V1NodeSelectorBuilder().build());
}
public V1NodeAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editOrNewRequiredDuringSchedulingIgnoredDuringExecutionLike(V1NodeSelector item) {
return withNewRequiredDuringSchedulingIgnoredDuringExecutionLike(getRequiredDuringSchedulingIgnoredDuringExecution() != null ? getRequiredDuringSchedulingIgnoredDuringExecution(): item);
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
V1NodeAffinityFluentImpl that = (V1NodeAffinityFluentImpl) o;
if (preferredDuringSchedulingIgnoredDuringExecution != null ? !preferredDuringSchedulingIgnoredDuringExecution.equals(that.preferredDuringSchedulingIgnoredDuringExecution) :that.preferredDuringSchedulingIgnoredDuringExecution != null) return false;
if (requiredDuringSchedulingIgnoredDuringExecution != null ? !requiredDuringSchedulingIgnoredDuringExecution.equals(that.requiredDuringSchedulingIgnoredDuringExecution) :that.requiredDuringSchedulingIgnoredDuringExecution != null) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(preferredDuringSchedulingIgnoredDuringExecution, requiredDuringSchedulingIgnoredDuringExecution, super.hashCode());
}
public class PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl extends V1PreferredSchedulingTermFluentImpl> implements V1NodeAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested,io.kubernetes.client.fluent.Nested {
private final V1PreferredSchedulingTermBuilder builder;
private final int index;
PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl(int index,V1PreferredSchedulingTerm item) {
this.index = index;
this.builder = new V1PreferredSchedulingTermBuilder(this, item);
}
PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl() {
this.index = -1;
this.builder = new V1PreferredSchedulingTermBuilder(this);
}
public N and() {
return (N) V1NodeAffinityFluentImpl.this.setToPreferredDuringSchedulingIgnoredDuringExecution(index,builder.build());
}
public N endPreferredDuringSchedulingIgnoredDuringExecution() {
return and();
}
}
public class RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl extends V1NodeSelectorFluentImpl> implements V1NodeAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested,io.kubernetes.client.fluent.Nested {
private final V1NodeSelectorBuilder builder;
RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl(V1NodeSelector item) {
this.builder = new V1NodeSelectorBuilder(this, item);
}
RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl() {
this.builder = new V1NodeSelectorBuilder(this);
}
public N and() {
return (N) V1NodeAffinityFluentImpl.this.withRequiredDuringSchedulingIgnoredDuringExecution(builder.build());
}
public N endRequiredDuringSchedulingIgnoredDuringExecution() {
return and();
}
}
}