io.kubernetes.client.openapi.models.V1beta1SupplementalGroupsStrategyOptionsFluentImpl Maven / Gradle / Ivy
package io.kubernetes.client.openapi.models;
import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.StringBuilder;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.kubernetes.client.fluent.Predicate;
import java.lang.StringBuffer;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class V1beta1SupplementalGroupsStrategyOptionsFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1beta1SupplementalGroupsStrategyOptionsFluent {
private List ranges;
private String rule;
public V1beta1SupplementalGroupsStrategyOptionsFluentImpl() {
}
public V1beta1SupplementalGroupsStrategyOptionsFluentImpl(V1beta1SupplementalGroupsStrategyOptions instance) {
this.withRanges(instance.getRanges());
this.withRule(instance.getRule());
}
public A addToRanges(int index,V1beta1IDRange item) {
if (this.ranges == null) {this.ranges = new ArrayList();}
V1beta1IDRangeBuilder builder = new V1beta1IDRangeBuilder(item);_visitables.get("ranges").add(index >= 0 ? index : _visitables.get("ranges").size(), builder);this.ranges.add(index >= 0 ? index : ranges.size(), builder); return (A)this;
}
public A setToRanges(int index,V1beta1IDRange item) {
if (this.ranges == null) {this.ranges = new ArrayList();}
V1beta1IDRangeBuilder builder = new V1beta1IDRangeBuilder(item);
if (index < 0 || index >= _visitables.get("ranges").size()) { _visitables.get("ranges").add(builder); } else { _visitables.get("ranges").set(index, builder);}
if (index < 0 || index >= ranges.size()) { ranges.add(builder); } else { ranges.set(index, builder);}
return (A)this;
}
public A addToRanges(V1beta1IDRange... items) {
if (this.ranges == null) {this.ranges = new ArrayList();}
for (V1beta1IDRange item : items) {V1beta1IDRangeBuilder builder = new V1beta1IDRangeBuilder(item);_visitables.get("ranges").add(builder);this.ranges.add(builder);} return (A)this;
}
public A addAllToRanges(Collection items) {
if (this.ranges == null) {this.ranges = new ArrayList();}
for (V1beta1IDRange item : items) {V1beta1IDRangeBuilder builder = new V1beta1IDRangeBuilder(item);_visitables.get("ranges").add(builder);this.ranges.add(builder);} return (A)this;
}
public A removeFromRanges(V1beta1IDRange... items) {
for (V1beta1IDRange item : items) {V1beta1IDRangeBuilder builder = new V1beta1IDRangeBuilder(item);_visitables.get("ranges").remove(builder);if (this.ranges != null) {this.ranges.remove(builder);}} return (A)this;
}
public A removeAllFromRanges(Collection items) {
for (V1beta1IDRange item : items) {V1beta1IDRangeBuilder builder = new V1beta1IDRangeBuilder(item);_visitables.get("ranges").remove(builder);if (this.ranges != null) {this.ranges.remove(builder);}} return (A)this;
}
public A removeMatchingFromRanges(io.kubernetes.client.fluent.Predicate predicate) {
if (ranges == null) return (A) this;
final Iterator each = ranges.iterator();
final List visitables = _visitables.get("ranges");
while (each.hasNext()) {
V1beta1IDRangeBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildRanges instead.
* @return The buildable object.
*/
@Deprecated public List getRanges() {
return build(ranges);
}
public List buildRanges() {
return build(ranges);
}
public V1beta1IDRange buildRange(int index) {
return this.ranges.get(index).build();
}
public V1beta1IDRange buildFirstRange() {
return this.ranges.get(0).build();
}
public V1beta1IDRange buildLastRange() {
return this.ranges.get(ranges.size() - 1).build();
}
public V1beta1IDRange buildMatchingRange(io.kubernetes.client.fluent.Predicate predicate) {
for (V1beta1IDRangeBuilder item: ranges) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingRange(io.kubernetes.client.fluent.Predicate predicate) {
for (V1beta1IDRangeBuilder item: ranges) { if(predicate.apply(item)){ return true;} } return false;
}
public A withRanges(List ranges) {
if (this.ranges != null) { _visitables.get("ranges").removeAll(this.ranges);}
if (ranges != null) {this.ranges = new ArrayList(); for (V1beta1IDRange item : ranges){this.addToRanges(item);}} else { this.ranges = null;} return (A) this;
}
public A withRanges(V1beta1IDRange... ranges) {
if (this.ranges != null) {this.ranges.clear();}
if (ranges != null) {for (V1beta1IDRange item :ranges){ this.addToRanges(item);}} return (A) this;
}
public Boolean hasRanges() {
return ranges != null && !ranges.isEmpty();
}
public V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested addNewRange() {
return new RangesNestedImpl();
}
public V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested addNewRangeLike(V1beta1IDRange item) {
return new RangesNestedImpl(-1, item);
}
public V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested setNewRangeLike(int index,V1beta1IDRange item) {
return new RangesNestedImpl(index, item);
}
public V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested editRange(int index) {
if (ranges.size() <= index) throw new RuntimeException("Can't edit ranges. Index exceeds size.");
return setNewRangeLike(index, buildRange(index));
}
public V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested editFirstRange() {
if (ranges.size() == 0) throw new RuntimeException("Can't edit first ranges. The list is empty.");
return setNewRangeLike(0, buildRange(0));
}
public V1beta1SupplementalGroupsStrategyOptionsFluent.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 V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested editMatchingRange(io.kubernetes.client.fluent.Predicate predicate) {
int index = -1;
for (int i=0;i extends V1beta1IDRangeFluentImpl> implements V1beta1SupplementalGroupsStrategyOptionsFluent.RangesNested,io.kubernetes.client.fluent.Nested {
private final V1beta1IDRangeBuilder builder;
private final int index;
RangesNestedImpl(int index,V1beta1IDRange item) {
this.index = index;
this.builder = new V1beta1IDRangeBuilder(this, item);
}
RangesNestedImpl() {
this.index = -1;
this.builder = new V1beta1IDRangeBuilder(this);
}
public N and() {
return (N) V1beta1SupplementalGroupsStrategyOptionsFluentImpl.this.setToRanges(index,builder.build());
}
public N endRange() {
return and();
}
}
}