io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.PlacementDecisionStatusFluent Maven / Gradle / Ivy
package io.fabric8.openclustermanagement.api.model.cluster.v1alpha1;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.util.Map;
/**
* Generated
*/
@SuppressWarnings("unchecked")
public class PlacementDecisionStatusFluent> extends BaseFluent{
public PlacementDecisionStatusFluent() {
}
public PlacementDecisionStatusFluent(PlacementDecisionStatus instance) {
this.copyInstance(instance);
}
private ArrayList decisions = new ArrayList();
private Map additionalProperties;
protected void copyInstance(PlacementDecisionStatus instance) {
instance = (instance != null ? instance : new PlacementDecisionStatus());
if (instance != null) {
this.withDecisions(instance.getDecisions());
this.withAdditionalProperties(instance.getAdditionalProperties());
}
}
public A addToDecisions(int index,ClusterDecision item) {
if (this.decisions == null) {this.decisions = new ArrayList();}
ClusterDecisionBuilder builder = new ClusterDecisionBuilder(item);
if (index < 0 || index >= decisions.size()) { _visitables.get("decisions").add(builder); decisions.add(builder); } else { _visitables.get("decisions").add(index, builder); decisions.add(index, builder);}
return (A)this;
}
public A setToDecisions(int index,ClusterDecision item) {
if (this.decisions == null) {this.decisions = new ArrayList();}
ClusterDecisionBuilder builder = new ClusterDecisionBuilder(item);
if (index < 0 || index >= decisions.size()) { _visitables.get("decisions").add(builder); decisions.add(builder); } else { _visitables.get("decisions").set(index, builder); decisions.set(index, builder);}
return (A)this;
}
public A addToDecisions(io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.ClusterDecision... items) {
if (this.decisions == null) {this.decisions = new ArrayList();}
for (ClusterDecision item : items) {ClusterDecisionBuilder builder = new ClusterDecisionBuilder(item);_visitables.get("decisions").add(builder);this.decisions.add(builder);} return (A)this;
}
public A addAllToDecisions(Collection items) {
if (this.decisions == null) {this.decisions = new ArrayList();}
for (ClusterDecision item : items) {ClusterDecisionBuilder builder = new ClusterDecisionBuilder(item);_visitables.get("decisions").add(builder);this.decisions.add(builder);} return (A)this;
}
public A removeFromDecisions(io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.ClusterDecision... items) {
if (this.decisions == null) return (A)this;
for (ClusterDecision item : items) {ClusterDecisionBuilder builder = new ClusterDecisionBuilder(item);_visitables.get("decisions").remove(builder); this.decisions.remove(builder);} return (A)this;
}
public A removeAllFromDecisions(Collection items) {
if (this.decisions == null) return (A)this;
for (ClusterDecision item : items) {ClusterDecisionBuilder builder = new ClusterDecisionBuilder(item);_visitables.get("decisions").remove(builder); this.decisions.remove(builder);} return (A)this;
}
public A removeMatchingFromDecisions(Predicate predicate) {
if (decisions == null) return (A) this;
final Iterator each = decisions.iterator();
final List visitables = _visitables.get("decisions");
while (each.hasNext()) {
ClusterDecisionBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public List buildDecisions() {
return this.decisions != null ? build(decisions) : null;
}
public ClusterDecision buildDecision(int index) {
return this.decisions.get(index).build();
}
public ClusterDecision buildFirstDecision() {
return this.decisions.get(0).build();
}
public ClusterDecision buildLastDecision() {
return this.decisions.get(decisions.size() - 1).build();
}
public ClusterDecision buildMatchingDecision(Predicate predicate) {
for (ClusterDecisionBuilder item : decisions) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingDecision(Predicate predicate) {
for (ClusterDecisionBuilder item : decisions) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A withDecisions(List decisions) {
if (this.decisions != null) {
this._visitables.get("decisions").clear();
}
if (decisions != null) {
this.decisions = new ArrayList();
for (ClusterDecision item : decisions) {
this.addToDecisions(item);
}
} else {
this.decisions = null;
}
return (A) this;
}
public A withDecisions(io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.ClusterDecision... decisions) {
if (this.decisions != null) {
this.decisions.clear();
_visitables.remove("decisions");
}
if (decisions != null) {
for (ClusterDecision item : decisions) {
this.addToDecisions(item);
}
}
return (A) this;
}
public boolean hasDecisions() {
return this.decisions != null && !this.decisions.isEmpty();
}
public A addNewDecision(String clusterName,String reason) {
return (A)addToDecisions(new ClusterDecision(clusterName, reason));
}
public DecisionsNested addNewDecision() {
return new DecisionsNested(-1, null);
}
public DecisionsNested addNewDecisionLike(ClusterDecision item) {
return new DecisionsNested(-1, item);
}
public DecisionsNested setNewDecisionLike(int index,ClusterDecision item) {
return new DecisionsNested(index, item);
}
public DecisionsNested editDecision(int index) {
if (decisions.size() <= index) throw new RuntimeException("Can't edit decisions. Index exceeds size.");
return setNewDecisionLike(index, buildDecision(index));
}
public DecisionsNested editFirstDecision() {
if (decisions.size() == 0) throw new RuntimeException("Can't edit first decisions. The list is empty.");
return setNewDecisionLike(0, buildDecision(0));
}
public DecisionsNested editLastDecision() {
int index = decisions.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last decisions. The list is empty.");
return setNewDecisionLike(index, buildDecision(index));
}
public DecisionsNested editMatchingDecision(Predicate predicate) {
int index = -1;
for (int i=0;i map) {
if(this.additionalProperties == null && map != null) { this.additionalProperties = new LinkedHashMap(); }
if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
}
public A removeFromAdditionalProperties(String key) {
if(this.additionalProperties == null) { return (A) this; }
if(key != null && this.additionalProperties != null) {this.additionalProperties.remove(key);} return (A)this;
}
public A removeFromAdditionalProperties(Map map) {
if(this.additionalProperties == null) { return (A) this; }
if(map != null) { for(Object key : map.keySet()) {if (this.additionalProperties != null){this.additionalProperties.remove(key);}}} return (A)this;
}
public Map getAdditionalProperties() {
return this.additionalProperties;
}
public A withAdditionalProperties(Map additionalProperties) {
if (additionalProperties == null) {
this.additionalProperties = null;
} else {
this.additionalProperties = new LinkedHashMap(additionalProperties);
}
return (A) this;
}
public boolean hasAdditionalProperties() {
return this.additionalProperties != null;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
PlacementDecisionStatusFluent that = (PlacementDecisionStatusFluent) o;
if (!java.util.Objects.equals(decisions, that.decisions)) return false;
if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(decisions, additionalProperties, super.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (decisions != null && !decisions.isEmpty()) { sb.append("decisions:"); sb.append(decisions + ","); }
if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
sb.append("}");
return sb.toString();
}
public class DecisionsNested extends ClusterDecisionFluent> implements Nested{
DecisionsNested(int index,ClusterDecision item) {
this.index = index;
this.builder = new ClusterDecisionBuilder(this, item);
}
ClusterDecisionBuilder builder;
int index;
public N and() {
return (N) PlacementDecisionStatusFluent.this.setToDecisions(index,builder.build());
}
public N endDecision() {
return and();
}
}
}