annotations.io.alauda.kubernetes.api.model.StatusDetailsFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import javax.validation.constraints.NotNull;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Integer;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class StatusDetailsFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements StatusDetailsFluent{
private List causes = new ArrayList();
private String group;
private String kind;
private String name;
private Integer retryAfterSeconds;
private String uid;
public StatusDetailsFluentImpl(){
}
public StatusDetailsFluentImpl(StatusDetails 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,StatusCause item){
StatusCauseBuilder builder = new StatusCauseBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.causes.add(index >= 0 ? index : causes.size(), builder); return (A)this;
}
public A setToCauses(int index,StatusCause item){
StatusCauseBuilder builder = new StatusCauseBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= causes.size()) { causes.add(builder); } else { causes.set(index, builder);}
return (A)this;
}
public A addToCauses(StatusCause... items){
for (StatusCause item : items) {StatusCauseBuilder builder = new StatusCauseBuilder(item);_visitables.add(builder);this.causes.add(builder);} return (A)this;
}
public A addAllToCauses(Collection items){
for (StatusCause item : items) {StatusCauseBuilder builder = new StatusCauseBuilder(item);_visitables.add(builder);this.causes.add(builder);} return (A)this;
}
public A removeFromCauses(StatusCause... items){
for (StatusCause item : items) {StatusCauseBuilder builder = new StatusCauseBuilder(item);_visitables.remove(builder);this.causes.remove(builder);} return (A)this;
}
public A removeAllFromCauses(Collection items){
for (StatusCause item : items) {StatusCauseBuilder builder = new StatusCauseBuilder(item);_visitables.remove(builder);this.causes.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildCauses instead.
*/
@Deprecated public List getCauses(){
return build(causes);
}
public List buildCauses(){
return build(causes);
}
public StatusCause buildCause(int index){
return this.causes.get(index).build();
}
public StatusCause buildFirstCause(){
return this.causes.get(0).build();
}
public StatusCause buildLastCause(){
return this.causes.get(causes.size() - 1).build();
}
public StatusCause buildMatchingCause(io.alauda.kubernetes.api.builder.Predicate predicate){
for (StatusCauseBuilder item: causes) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withCauses(List causes){
_visitables.removeAll(this.causes);
this.causes.clear();
if (causes != null) {for (StatusCause item : causes){this.addToCauses(item);}} return (A) this;
}
public A withCauses(StatusCause... causes){
this.causes.clear(); if (causes != null) {for (StatusCause item :causes){ this.addToCauses(item);}} return (A) this;
}
public Boolean hasCauses(){
return causes!= null && !causes.isEmpty();
}
public StatusDetailsFluent.CausesNested addNewCause(){
return new CausesNestedImpl();
}
public StatusDetailsFluent.CausesNested addNewCauseLike(StatusCause item){
return new CausesNestedImpl(-1, item);
}
public StatusDetailsFluent.CausesNested setNewCauseLike(int index,StatusCause item){
return new CausesNestedImpl(index, item);
}
public StatusDetailsFluent.CausesNested editCause(int index){
if (causes.size() <= index) throw new RuntimeException("Can't edit causes. Index exceeds size.");
return setNewCauseLike(index, buildCause(index));
}
public StatusDetailsFluent.CausesNested editFirstCause(){
if (causes.size() == 0) throw new RuntimeException("Can't edit first causes. The list is empty.");
return setNewCauseLike(0, buildCause(0));
}
public StatusDetailsFluent.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 StatusDetailsFluent.CausesNested editMatchingCause(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends StatusCauseFluentImpl> implements StatusDetailsFluent.CausesNested,io.alauda.kubernetes.api.builder.Nested{
private final StatusCauseBuilder builder;
private final int index;
CausesNestedImpl(int index,StatusCause item){
this.index = index;
this.builder = new StatusCauseBuilder(this, item);
}
CausesNestedImpl(){
this.index = -1;
this.builder = new StatusCauseBuilder(this);
}
public N and(){
return (N) StatusDetailsFluentImpl.this.setToCauses(index, builder.build());
}
public N endCause(){
return and();
}
}
}