io.alauda.kubernetes.api.model.InitializersFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.List;
import java.lang.Boolean;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;
public class InitializersFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements InitializersFluent{
private List pending = new ArrayList();
private StatusBuilder result;
public InitializersFluentImpl(){
}
public InitializersFluentImpl(Initializers instance){
this.withPending(instance.getPending());
this.withResult(instance.getResult());
}
public A addToPending(int index,Initializer item){
InitializerBuilder builder = new InitializerBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.pending.add(index >= 0 ? index : pending.size(), builder); return (A)this;
}
public A setToPending(int index,Initializer item){
InitializerBuilder builder = new InitializerBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= pending.size()) { pending.add(builder); } else { pending.set(index, builder);}
return (A)this;
}
public A addToPending(Initializer... items){
for (Initializer item : items) {InitializerBuilder builder = new InitializerBuilder(item);_visitables.add(builder);this.pending.add(builder);} return (A)this;
}
public A addAllToPending(Collection items){
for (Initializer item : items) {InitializerBuilder builder = new InitializerBuilder(item);_visitables.add(builder);this.pending.add(builder);} return (A)this;
}
public A removeFromPending(Initializer... items){
for (Initializer item : items) {InitializerBuilder builder = new InitializerBuilder(item);_visitables.remove(builder);this.pending.remove(builder);} return (A)this;
}
public A removeAllFromPending(Collection items){
for (Initializer item : items) {InitializerBuilder builder = new InitializerBuilder(item);_visitables.remove(builder);this.pending.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildPending instead.
*/
@Deprecated public List getPending(){
return build(pending);
}
public List buildPending(){
return build(pending);
}
public Initializer buildPending(int index){
return this.pending.get(index).build();
}
public Initializer buildFirstPending(){
return this.pending.get(0).build();
}
public Initializer buildLastPending(){
return this.pending.get(pending.size() - 1).build();
}
public Initializer buildMatchingPending(io.alauda.kubernetes.api.builder.Predicate predicate){
for (InitializerBuilder item: pending) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withPending(List pending){
_visitables.removeAll(this.pending);
this.pending.clear();
if (pending != null) {for (Initializer item : pending){this.addToPending(item);}} return (A) this;
}
public A withPending(Initializer... pending){
this.pending.clear(); if (pending != null) {for (Initializer item :pending){ this.addToPending(item);}} return (A) this;
}
public Boolean hasPending(){
return pending!= null && !pending.isEmpty();
}
public InitializersFluent.PendingNested addNewPending(){
return new PendingNestedImpl();
}
public InitializersFluent.PendingNested addNewPendingLike(Initializer item){
return new PendingNestedImpl(-1, item);
}
public InitializersFluent.PendingNested setNewPendingLike(int index,Initializer item){
return new PendingNestedImpl(index, item);
}
public InitializersFluent.PendingNested editPending(int index){
if (pending.size() <= index) throw new RuntimeException("Can't edit pending. Index exceeds size.");
return setNewPendingLike(index, buildPending(index));
}
public InitializersFluent.PendingNested editFirstPending(){
if (pending.size() == 0) throw new RuntimeException("Can't edit first pending. The list is empty.");
return setNewPendingLike(0, buildPending(0));
}
public InitializersFluent.PendingNested editLastPending(){
int index = pending.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last pending. The list is empty.");
return setNewPendingLike(index, buildPending(index));
}
public InitializersFluent.PendingNested editMatchingPending(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i withNewResult(){
return new ResultNestedImpl();
}
public InitializersFluent.ResultNested withNewResultLike(Status item){
return new ResultNestedImpl(item);
}
public InitializersFluent.ResultNested editResult(){
return withNewResultLike(getResult());
}
public InitializersFluent.ResultNested editOrNewResult(){
return withNewResultLike(getResult() != null ? getResult(): new StatusBuilder().build());
}
public InitializersFluent.ResultNested editOrNewResultLike(Status item){
return withNewResultLike(getResult() != null ? getResult(): item);
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
InitializersFluentImpl that = (InitializersFluentImpl) o;
if (pending != null ? !pending.equals(that.pending) :that.pending != null) return false;
if (result != null ? !result.equals(that.result) :that.result != null) return false;
return true;
}
public class PendingNestedImpl extends InitializerFluentImpl> implements InitializersFluent.PendingNested,io.alauda.kubernetes.api.builder.Nested{
private final InitializerBuilder builder;
private final int index;
PendingNestedImpl(int index,Initializer item){
this.index = index;
this.builder = new InitializerBuilder(this, item);
}
PendingNestedImpl(){
this.index = -1;
this.builder = new InitializerBuilder(this);
}
public N and(){
return (N) InitializersFluentImpl.this.setToPending(index, builder.build());
}
public N endPending(){
return and();
}
}
public class ResultNestedImpl extends StatusFluentImpl> implements InitializersFluent.ResultNested,io.alauda.kubernetes.api.builder.Nested{
private final StatusBuilder builder;
ResultNestedImpl(Status item){
this.builder = new StatusBuilder(this, item);
}
ResultNestedImpl(){
this.builder = new StatusBuilder(this);
}
public N and(){
return (N) InitializersFluentImpl.this.withResult(builder.build());
}
public N endResult(){
return and();
}
}
}