io.alauda.devops.api.model.RouteIngressFluentImpl Maven / Gradle / Ivy
package io.alauda.devops.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 io.alauda.kubernetes.api.builder.Predicate;
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 RouteIngressFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements RouteIngressFluent{
private List conditions = new ArrayList();
private String host;
private String routerCanonicalHostname;
private String routerName;
private String wildcardPolicy;
public RouteIngressFluentImpl(){
}
public RouteIngressFluentImpl(RouteIngress instance){
this.withConditions(instance.getConditions());
this.withHost(instance.getHost());
this.withRouterCanonicalHostname(instance.getRouterCanonicalHostname());
this.withRouterName(instance.getRouterName());
this.withWildcardPolicy(instance.getWildcardPolicy());
}
public A addToConditions(int index,RouteIngressCondition item){
RouteIngressConditionBuilder builder = new RouteIngressConditionBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.conditions.add(index >= 0 ? index : conditions.size(), builder); return (A)this;
}
public A setToConditions(int index,RouteIngressCondition item){
RouteIngressConditionBuilder builder = new RouteIngressConditionBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= conditions.size()) { conditions.add(builder); } else { conditions.set(index, builder);}
return (A)this;
}
public A addToConditions(RouteIngressCondition... items){
for (RouteIngressCondition item : items) {RouteIngressConditionBuilder builder = new RouteIngressConditionBuilder(item);_visitables.add(builder);this.conditions.add(builder);} return (A)this;
}
public A addAllToConditions(Collection items){
for (RouteIngressCondition item : items) {RouteIngressConditionBuilder builder = new RouteIngressConditionBuilder(item);_visitables.add(builder);this.conditions.add(builder);} return (A)this;
}
public A removeFromConditions(RouteIngressCondition... items){
for (RouteIngressCondition item : items) {RouteIngressConditionBuilder builder = new RouteIngressConditionBuilder(item);_visitables.remove(builder);this.conditions.remove(builder);} return (A)this;
}
public A removeAllFromConditions(Collection items){
for (RouteIngressCondition item : items) {RouteIngressConditionBuilder builder = new RouteIngressConditionBuilder(item);_visitables.remove(builder);this.conditions.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildConditions instead.
*/
@Deprecated public List getConditions(){
return build(conditions);
}
public List buildConditions(){
return build(conditions);
}
public RouteIngressCondition buildCondition(int index){
return this.conditions.get(index).build();
}
public RouteIngressCondition buildFirstCondition(){
return this.conditions.get(0).build();
}
public RouteIngressCondition buildLastCondition(){
return this.conditions.get(conditions.size() - 1).build();
}
public RouteIngressCondition buildMatchingCondition(io.alauda.kubernetes.api.builder.Predicate predicate){
for (RouteIngressConditionBuilder item: conditions) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withConditions(List conditions){
_visitables.removeAll(this.conditions);
this.conditions.clear();
if (conditions != null) {for (RouteIngressCondition item : conditions){this.addToConditions(item);}} return (A) this;
}
public A withConditions(RouteIngressCondition... conditions){
this.conditions.clear(); if (conditions != null) {for (RouteIngressCondition item :conditions){ this.addToConditions(item);}} return (A) this;
}
public Boolean hasConditions(){
return conditions!= null && !conditions.isEmpty();
}
public RouteIngressFluent.ConditionsNested addNewCondition(){
return new ConditionsNestedImpl();
}
public RouteIngressFluent.ConditionsNested addNewConditionLike(RouteIngressCondition item){
return new ConditionsNestedImpl(-1, item);
}
public RouteIngressFluent.ConditionsNested setNewConditionLike(int index,RouteIngressCondition item){
return new ConditionsNestedImpl(index, item);
}
public RouteIngressFluent.ConditionsNested editCondition(int index){
if (conditions.size() <= index) throw new RuntimeException("Can't edit conditions. Index exceeds size.");
return setNewConditionLike(index, buildCondition(index));
}
public RouteIngressFluent.ConditionsNested editFirstCondition(){
if (conditions.size() == 0) throw new RuntimeException("Can't edit first conditions. The list is empty.");
return setNewConditionLike(0, buildCondition(0));
}
public RouteIngressFluent.ConditionsNested editLastCondition(){
int index = conditions.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last conditions. The list is empty.");
return setNewConditionLike(index, buildCondition(index));
}
public RouteIngressFluent.ConditionsNested editMatchingCondition(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends RouteIngressConditionFluentImpl> implements RouteIngressFluent.ConditionsNested,io.alauda.kubernetes.api.builder.Nested{
private final RouteIngressConditionBuilder builder;
private final int index;
ConditionsNestedImpl(int index,RouteIngressCondition item){
this.index = index;
this.builder = new RouteIngressConditionBuilder(this, item);
}
ConditionsNestedImpl(){
this.index = -1;
this.builder = new RouteIngressConditionBuilder(this);
}
public N and(){
return (N) RouteIngressFluentImpl.this.setToConditions(index, builder.build());
}
public N endCondition(){
return and();
}
}
}