me.snowdrop.istio.api.model.v1.mixer.config.RuleFluentImpl Maven / Gradle / Ivy
package me.snowdrop.istio.api.model.v1.mixer.config;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import me.snowdrop.istio.api.builder.Nested;
import java.lang.String;
import me.snowdrop.istio.api.builder.Predicate;
import java.lang.Deprecated;
import javax.validation.Valid;
import me.snowdrop.istio.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class RuleFluentImpl> extends me.snowdrop.istio.api.builder.BaseFluent implements RuleFluent{
private List actions;
private String match;
public RuleFluentImpl(){
}
public RuleFluentImpl(Rule instance){
this.withActions(instance.getActions());
this.withMatch(instance.getMatch());
}
public A addToActions(int index,Action item){
if (this.actions == null) {this.actions = new ArrayList();}
ActionBuilder builder = new ActionBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.actions.add(index >= 0 ? index : actions.size(), builder); return (A)this;
}
public A setToActions(int index,Action item){
if (this.actions == null) {this.actions = new ArrayList();}
ActionBuilder builder = new ActionBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= actions.size()) { actions.add(builder); } else { actions.set(index, builder);}
return (A)this;
}
public A addToActions(Action... items){
if (this.actions == null) {this.actions = new ArrayList();}
for (Action item : items) {ActionBuilder builder = new ActionBuilder(item);_visitables.add(builder);this.actions.add(builder);} return (A)this;
}
public A addAllToActions(Collection items){
if (this.actions == null) {this.actions = new ArrayList();}
for (Action item : items) {ActionBuilder builder = new ActionBuilder(item);_visitables.add(builder);this.actions.add(builder);} return (A)this;
}
public A removeFromActions(Action... items){
for (Action item : items) {ActionBuilder builder = new ActionBuilder(item);_visitables.remove(builder);if (this.actions != null) {this.actions.remove(builder);}} return (A)this;
}
public A removeAllFromActions(Collection items){
for (Action item : items) {ActionBuilder builder = new ActionBuilder(item);_visitables.remove(builder);if (this.actions != null) {this.actions.remove(builder);}} return (A)this;
}
/**
* This method has been deprecated, please use method buildActions instead.
*/
@Deprecated public List getActions(){
return build(actions);
}
public List buildActions(){
return build(actions);
}
public Action buildAction(int index){
return this.actions.get(index).build();
}
public Action buildFirstAction(){
return this.actions.get(0).build();
}
public Action buildLastAction(){
return this.actions.get(actions.size() - 1).build();
}
public Action buildMatchingAction(me.snowdrop.istio.api.builder.Predicate predicate){
for (ActionBuilder item: actions) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withActions(List actions){
if (this.actions != null) { _visitables.removeAll(this.actions);}
if (actions != null) {this.actions = new ArrayList(); for (Action item : actions){this.addToActions(item);}} else { this.actions = null;} return (A) this;
}
public A withActions(Action... actions){
this.actions.clear(); if (actions != null) {for (Action item :actions){ this.addToActions(item);}} return (A) this;
}
public Boolean hasActions(){
return actions != null && !actions.isEmpty();
}
public RuleFluent.ActionsNested addNewAction(){
return new ActionsNestedImpl();
}
public RuleFluent.ActionsNested addNewActionLike(Action item){
return new ActionsNestedImpl(-1, item);
}
public RuleFluent.ActionsNested setNewActionLike(int index,Action item){
return new ActionsNestedImpl(index, item);
}
public RuleFluent.ActionsNested editAction(int index){
if (actions.size() <= index) throw new RuntimeException("Can't edit actions. Index exceeds size.");
return setNewActionLike(index, buildAction(index));
}
public RuleFluent.ActionsNested editFirstAction(){
if (actions.size() == 0) throw new RuntimeException("Can't edit first actions. The list is empty.");
return setNewActionLike(0, buildAction(0));
}
public RuleFluent.ActionsNested editLastAction(){
int index = actions.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last actions. The list is empty.");
return setNewActionLike(index, buildAction(index));
}
public RuleFluent.ActionsNested editMatchingAction(me.snowdrop.istio.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends ActionFluentImpl> implements RuleFluent.ActionsNested,me.snowdrop.istio.api.builder.Nested{
private final ActionBuilder builder;
private final int index;
ActionsNestedImpl(int index,Action item){
this.index = index;
this.builder = new ActionBuilder(this, item);
}
ActionsNestedImpl(){
this.index = -1;
this.builder = new ActionBuilder(this);
}
public N and(){
return (N) RuleFluentImpl.this.setToActions(index, builder.build());
}
public N endAction(){
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy