annotations.io.alauda.kubernetes.api.model.extensions.KubernetesRunAsUserStrategyOptionsFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model.extensions;
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.lang.Long;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class KubernetesRunAsUserStrategyOptionsFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements KubernetesRunAsUserStrategyOptionsFluent{
private List ranges = new ArrayList();
private String rule;
public KubernetesRunAsUserStrategyOptionsFluentImpl(){
}
public KubernetesRunAsUserStrategyOptionsFluentImpl(KubernetesRunAsUserStrategyOptions instance){
this.withRanges(instance.getRanges());
this.withRule(instance.getRule());
}
public A addToRanges(int index,IDRange item){
IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.ranges.add(index >= 0 ? index : ranges.size(), builder); return (A)this;
}
public A setToRanges(int index,IDRange item){
IDRangeBuilder builder = new IDRangeBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= ranges.size()) { ranges.add(builder); } else { ranges.set(index, builder);}
return (A)this;
}
public A addToRanges(IDRange... items){
for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.add(builder);this.ranges.add(builder);} return (A)this;
}
public A addAllToRanges(Collection items){
for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.add(builder);this.ranges.add(builder);} return (A)this;
}
public A removeFromRanges(IDRange... items){
for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.remove(builder);this.ranges.remove(builder);} return (A)this;
}
public A removeAllFromRanges(Collection items){
for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.remove(builder);this.ranges.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildRanges instead.
*/
@Deprecated public List getRanges(){
return build(ranges);
}
public List buildRanges(){
return build(ranges);
}
public IDRange buildRange(int index){
return this.ranges.get(index).build();
}
public IDRange buildFirstRange(){
return this.ranges.get(0).build();
}
public IDRange buildLastRange(){
return this.ranges.get(ranges.size() - 1).build();
}
public IDRange buildMatchingRange(io.alauda.kubernetes.api.builder.Predicate predicate){
for (IDRangeBuilder item: ranges) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withRanges(List ranges){
_visitables.removeAll(this.ranges);
this.ranges.clear();
if (ranges != null) {for (IDRange item : ranges){this.addToRanges(item);}} return (A) this;
}
public A withRanges(IDRange... ranges){
this.ranges.clear(); if (ranges != null) {for (IDRange item :ranges){ this.addToRanges(item);}} return (A) this;
}
public Boolean hasRanges(){
return ranges!= null && !ranges.isEmpty();
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested addNewRange(){
return new RangesNestedImpl();
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested addNewRangeLike(IDRange item){
return new RangesNestedImpl(-1, item);
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested setNewRangeLike(int index,IDRange item){
return new RangesNestedImpl(index, item);
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested editRange(int index){
if (ranges.size() <= index) throw new RuntimeException("Can't edit ranges. Index exceeds size.");
return setNewRangeLike(index, buildRange(index));
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested editFirstRange(){
if (ranges.size() == 0) throw new RuntimeException("Can't edit first ranges. The list is empty.");
return setNewRangeLike(0, buildRange(0));
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested editLastRange(){
int index = ranges.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last ranges. The list is empty.");
return setNewRangeLike(index, buildRange(index));
}
public KubernetesRunAsUserStrategyOptionsFluent.RangesNested editMatchingRange(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends IDRangeFluentImpl> implements KubernetesRunAsUserStrategyOptionsFluent.RangesNested,io.alauda.kubernetes.api.builder.Nested{
private final IDRangeBuilder builder;
private final int index;
RangesNestedImpl(int index,IDRange item){
this.index = index;
this.builder = new IDRangeBuilder(this, item);
}
RangesNestedImpl(){
this.index = -1;
this.builder = new IDRangeBuilder(this);
}
public N and(){
return (N) KubernetesRunAsUserStrategyOptionsFluentImpl.this.setToRanges(index, builder.build());
}
public N endRange(){
return and();
}
}
}