All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.kubernetes.client.openapi.models.V1LimitRangeSpecFluentImpl Maven / Gradle / Ivy

package io.kubernetes.client.openapi.models;

import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.function.Predicate;
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;

 /**
  * Generated
  */
  @SuppressWarnings(value = "unchecked")
  public class V1LimitRangeSpecFluentImpl> extends BaseFluent implements V1LimitRangeSpecFluent{
  public V1LimitRangeSpecFluentImpl() {
  }
  public V1LimitRangeSpecFluentImpl(V1LimitRangeSpec instance) {
    if (instance != null) {
      this.withLimits(instance.getLimits());
    }
  }
  private ArrayList limits;
  public A addToLimits(int index,V1LimitRangeItem item) {
    if (this.limits == null) {this.limits = new ArrayList();}
    V1LimitRangeItemBuilder builder = new V1LimitRangeItemBuilder(item);
    if (index < 0 || index >= limits.size()) { _visitables.get("limits").add(builder); limits.add(builder); } else { _visitables.get("limits").add(index, builder); limits.add(index, builder);}
    return (A)this;
  }
  public A setToLimits(int index,V1LimitRangeItem item) {
    if (this.limits == null) {this.limits = new ArrayList();}
    V1LimitRangeItemBuilder builder = new V1LimitRangeItemBuilder(item);
    if (index < 0 || index >= limits.size()) { _visitables.get("limits").add(builder); limits.add(builder); } else { _visitables.get("limits").set(index, builder); limits.set(index, builder);}
    return (A)this;
  }
  public A addToLimits(io.kubernetes.client.openapi.models.V1LimitRangeItem... items) {
    if (this.limits == null) {this.limits = new ArrayList();}
    for (V1LimitRangeItem item : items) {V1LimitRangeItemBuilder builder = new V1LimitRangeItemBuilder(item);_visitables.get("limits").add(builder);this.limits.add(builder);} return (A)this;
  }
  public A addAllToLimits(Collection items) {
    if (this.limits == null) {this.limits = new ArrayList();}
    for (V1LimitRangeItem item : items) {V1LimitRangeItemBuilder builder = new V1LimitRangeItemBuilder(item);_visitables.get("limits").add(builder);this.limits.add(builder);} return (A)this;
  }
  public A removeFromLimits(io.kubernetes.client.openapi.models.V1LimitRangeItem... items) {
    for (V1LimitRangeItem item : items) {V1LimitRangeItemBuilder builder = new V1LimitRangeItemBuilder(item);_visitables.get("limits").remove(builder);if (this.limits != null) {this.limits.remove(builder);}} return (A)this;
  }
  public A removeAllFromLimits(Collection items) {
    for (V1LimitRangeItem item : items) {V1LimitRangeItemBuilder builder = new V1LimitRangeItemBuilder(item);_visitables.get("limits").remove(builder);if (this.limits != null) {this.limits.remove(builder);}} return (A)this;
  }
  public A removeMatchingFromLimits(Predicate predicate) {
    if (limits == null) return (A) this;
    final Iterator each = limits.iterator();
    final List visitables = _visitables.get("limits");
    while (each.hasNext()) {
      V1LimitRangeItemBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  /**
   * This method has been deprecated, please use method buildLimits instead.
   * @return The buildable object.
   */
  @Deprecated
  public List getLimits() {
    return limits != null ? build(limits) : null;
  }
  public List buildLimits() {
    return limits != null ? build(limits) : null;
  }
  public V1LimitRangeItem buildLimit(int index) {
    return this.limits.get(index).build();
  }
  public V1LimitRangeItem buildFirstLimit() {
    return this.limits.get(0).build();
  }
  public V1LimitRangeItem buildLastLimit() {
    return this.limits.get(limits.size() - 1).build();
  }
  public V1LimitRangeItem buildMatchingLimit(Predicate predicate) {
    for (V1LimitRangeItemBuilder item: limits) { if(predicate.test(item)){ return item.build();} } return null;
  }
  public Boolean hasMatchingLimit(Predicate predicate) {
    for (V1LimitRangeItemBuilder item: limits) { if(predicate.test(item)){ return true;} } return false;
  }
  public A withLimits(List limits) {
    if (this.limits != null) { _visitables.get("limits").clear();}
    if (limits != null) {this.limits = new ArrayList(); for (V1LimitRangeItem item : limits){this.addToLimits(item);}} else { this.limits = null;} return (A) this;
  }
  public A withLimits(io.kubernetes.client.openapi.models.V1LimitRangeItem... limits) {
    if (this.limits != null) {this.limits.clear(); _visitables.remove("limits"); }
    if (limits != null) {for (V1LimitRangeItem item :limits){ this.addToLimits(item);}} return (A) this;
  }
  public Boolean hasLimits() {
    return limits != null && !limits.isEmpty();
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested addNewLimit() {
    return new V1LimitRangeSpecFluentImpl.LimitsNestedImpl();
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested addNewLimitLike(V1LimitRangeItem item) {
    return new V1LimitRangeSpecFluentImpl.LimitsNestedImpl(-1, item);
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested setNewLimitLike(int index,V1LimitRangeItem item) {
    return new V1LimitRangeSpecFluentImpl.LimitsNestedImpl(index, item);
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested editLimit(int index) {
    if (limits.size() <= index) throw new RuntimeException("Can't edit limits. Index exceeds size.");
    return setNewLimitLike(index, buildLimit(index));
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested editFirstLimit() {
    if (limits.size() == 0) throw new RuntimeException("Can't edit first limits. The list is empty.");
    return setNewLimitLike(0, buildLimit(0));
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested editLastLimit() {
    int index = limits.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last limits. The list is empty.");
    return setNewLimitLike(index, buildLimit(index));
  }
  public V1LimitRangeSpecFluentImpl.LimitsNested editMatchingLimit(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1LimitRangeItemFluentImpl> implements V1LimitRangeSpecFluentImpl.LimitsNested,Nested{
    LimitsNestedImpl(int index,V1LimitRangeItem item) {
      this.index = index;
      this.builder = new V1LimitRangeItemBuilder(this, item);
    }
    LimitsNestedImpl() {
      this.index = -1;
      this.builder = new V1LimitRangeItemBuilder(this);
    }
    V1LimitRangeItemBuilder builder;
    int index;
    public N and() {
      return (N) V1LimitRangeSpecFluentImpl.this.setToLimits(index,builder.build());
    }
    public N endLimit() {
      return and();
    }
    
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy