io.kubernetes.client.openapi.models.V1StatusDetailsFluentImpl 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.Integer;
import java.lang.StringBuffer;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class V1StatusDetailsFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1StatusDetailsFluent {
private List causes;
private String group;
private String kind;
private String name;
private Integer retryAfterSeconds;
private String uid;
public V1StatusDetailsFluentImpl() {
}
public V1StatusDetailsFluentImpl(V1StatusDetails instance) {
this.withCauses(instance.getCauses());
this.withGroup(instance.getGroup());
this.withKind(instance.getKind());
this.withName(instance.getName());
this.withRetryAfterSeconds(instance.getRetryAfterSeconds());
this.withUid(instance.getUid());
}
public A addToCauses(int index,V1StatusCause item) {
if (this.causes == null) {this.causes = new ArrayList();}
V1StatusCauseBuilder builder = new V1StatusCauseBuilder(item);_visitables.get("causes").add(index >= 0 ? index : _visitables.get("causes").size(), builder);this.causes.add(index >= 0 ? index : causes.size(), builder); return (A)this;
}
public A setToCauses(int index,V1StatusCause item) {
if (this.causes == null) {this.causes = new ArrayList();}
V1StatusCauseBuilder builder = new V1StatusCauseBuilder(item);
if (index < 0 || index >= _visitables.get("causes").size()) { _visitables.get("causes").add(builder); } else { _visitables.get("causes").set(index, builder);}
if (index < 0 || index >= causes.size()) { causes.add(builder); } else { causes.set(index, builder);}
return (A)this;
}
public A addToCauses(V1StatusCause... items) {
if (this.causes == null) {this.causes = new ArrayList();}
for (V1StatusCause item : items) {V1StatusCauseBuilder builder = new V1StatusCauseBuilder(item);_visitables.get("causes").add(builder);this.causes.add(builder);} return (A)this;
}
public A addAllToCauses(Collection items) {
if (this.causes == null) {this.causes = new ArrayList();}
for (V1StatusCause item : items) {V1StatusCauseBuilder builder = new V1StatusCauseBuilder(item);_visitables.get("causes").add(builder);this.causes.add(builder);} return (A)this;
}
public A removeFromCauses(V1StatusCause... items) {
for (V1StatusCause item : items) {V1StatusCauseBuilder builder = new V1StatusCauseBuilder(item);_visitables.get("causes").remove(builder);if (this.causes != null) {this.causes.remove(builder);}} return (A)this;
}
public A removeAllFromCauses(Collection items) {
for (V1StatusCause item : items) {V1StatusCauseBuilder builder = new V1StatusCauseBuilder(item);_visitables.get("causes").remove(builder);if (this.causes != null) {this.causes.remove(builder);}} return (A)this;
}
public A removeMatchingFromCauses(io.kubernetes.client.fluent.Predicate predicate) {
if (causes == null) return (A) this;
final Iterator each = causes.iterator();
final List visitables = _visitables.get("causes");
while (each.hasNext()) {
V1StatusCauseBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildCauses instead.
* @return The buildable object.
*/
@Deprecated public List getCauses() {
return build(causes);
}
public List buildCauses() {
return build(causes);
}
public V1StatusCause buildCause(int index) {
return this.causes.get(index).build();
}
public V1StatusCause buildFirstCause() {
return this.causes.get(0).build();
}
public V1StatusCause buildLastCause() {
return this.causes.get(causes.size() - 1).build();
}
public V1StatusCause buildMatchingCause(io.kubernetes.client.fluent.Predicate predicate) {
for (V1StatusCauseBuilder item: causes) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingCause(io.kubernetes.client.fluent.Predicate predicate) {
for (V1StatusCauseBuilder item: causes) { if(predicate.apply(item)){ return true;} } return false;
}
public A withCauses(List causes) {
if (this.causes != null) { _visitables.get("causes").removeAll(this.causes);}
if (causes != null) {this.causes = new ArrayList(); for (V1StatusCause item : causes){this.addToCauses(item);}} else { this.causes = null;} return (A) this;
}
public A withCauses(V1StatusCause... causes) {
if (this.causes != null) {this.causes.clear();}
if (causes != null) {for (V1StatusCause item :causes){ this.addToCauses(item);}} return (A) this;
}
public Boolean hasCauses() {
return causes != null && !causes.isEmpty();
}
public V1StatusDetailsFluent.CausesNested addNewCause() {
return new CausesNestedImpl();
}
public V1StatusDetailsFluent.CausesNested addNewCauseLike(V1StatusCause item) {
return new CausesNestedImpl(-1, item);
}
public V1StatusDetailsFluent.CausesNested setNewCauseLike(int index,V1StatusCause item) {
return new CausesNestedImpl(index, item);
}
public V1StatusDetailsFluent.CausesNested editCause(int index) {
if (causes.size() <= index) throw new RuntimeException("Can't edit causes. Index exceeds size.");
return setNewCauseLike(index, buildCause(index));
}
public V1StatusDetailsFluent.CausesNested editFirstCause() {
if (causes.size() == 0) throw new RuntimeException("Can't edit first causes. The list is empty.");
return setNewCauseLike(0, buildCause(0));
}
public V1StatusDetailsFluent.CausesNested editLastCause() {
int index = causes.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last causes. The list is empty.");
return setNewCauseLike(index, buildCause(index));
}
public V1StatusDetailsFluent.CausesNested editMatchingCause(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i extends V1StatusCauseFluentImpl> implements V1StatusDetailsFluent.CausesNested,io.kubernetes.client.fluent.Nested {
private final V1StatusCauseBuilder builder;
private final int index;
CausesNestedImpl(int index,V1StatusCause item) {
this.index = index;
this.builder = new V1StatusCauseBuilder(this, item);
}
CausesNestedImpl() {
this.index = -1;
this.builder = new V1StatusCauseBuilder(this);
}
public N and() {
return (N) V1StatusDetailsFluentImpl.this.setToCauses(index,builder.build());
}
public N endCause() {
return and();
}
}
}