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

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

There is a newer version: 22.0.0
Show newest version
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 io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class V1AggregationRuleFluent> extends BaseFluent{
  public V1AggregationRuleFluent() {
  }
  
  public V1AggregationRuleFluent(V1AggregationRule instance) {
    this.copyInstance(instance);
  }
  private ArrayList clusterRoleSelectors;
  
  protected void copyInstance(V1AggregationRule instance) {
    instance = (instance != null ? instance : new V1AggregationRule());
    if (instance != null) {
          this.withClusterRoleSelectors(instance.getClusterRoleSelectors());
        }
  }
  
  public A addToClusterRoleSelectors(int index,V1LabelSelector item) {
    if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
    V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);
    if (index < 0 || index >= clusterRoleSelectors.size()) { _visitables.get("clusterRoleSelectors").add(builder); clusterRoleSelectors.add(builder); } else { _visitables.get("clusterRoleSelectors").add(index, builder); clusterRoleSelectors.add(index, builder);}
    return (A)this;
  }
  
  public A setToClusterRoleSelectors(int index,V1LabelSelector item) {
    if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
    V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);
    if (index < 0 || index >= clusterRoleSelectors.size()) { _visitables.get("clusterRoleSelectors").add(builder); clusterRoleSelectors.add(builder); } else { _visitables.get("clusterRoleSelectors").set(index, builder); clusterRoleSelectors.set(index, builder);}
    return (A)this;
  }
  
  public A addToClusterRoleSelectors(io.kubernetes.client.openapi.models.V1LabelSelector... items) {
    if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
    for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").add(builder);this.clusterRoleSelectors.add(builder);} return (A)this;
  }
  
  public A addAllToClusterRoleSelectors(Collection items) {
    if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
    for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").add(builder);this.clusterRoleSelectors.add(builder);} return (A)this;
  }
  
  public A removeFromClusterRoleSelectors(io.kubernetes.client.openapi.models.V1LabelSelector... items) {
    if (this.clusterRoleSelectors == null) return (A)this;
    for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").remove(builder); this.clusterRoleSelectors.remove(builder);} return (A)this;
  }
  
  public A removeAllFromClusterRoleSelectors(Collection items) {
    if (this.clusterRoleSelectors == null) return (A)this;
    for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").remove(builder); this.clusterRoleSelectors.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromClusterRoleSelectors(Predicate predicate) {
    if (clusterRoleSelectors == null) return (A) this;
    final Iterator each = clusterRoleSelectors.iterator();
    final List visitables = _visitables.get("clusterRoleSelectors");
    while (each.hasNext()) {
      V1LabelSelectorBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildClusterRoleSelectors() {
    return this.clusterRoleSelectors != null ? build(clusterRoleSelectors) : null;
  }
  
  public V1LabelSelector buildClusterRoleSelector(int index) {
    return this.clusterRoleSelectors.get(index).build();
  }
  
  public V1LabelSelector buildFirstClusterRoleSelector() {
    return this.clusterRoleSelectors.get(0).build();
  }
  
  public V1LabelSelector buildLastClusterRoleSelector() {
    return this.clusterRoleSelectors.get(clusterRoleSelectors.size() - 1).build();
  }
  
  public V1LabelSelector buildMatchingClusterRoleSelector(Predicate predicate) {
      for (V1LabelSelectorBuilder item : clusterRoleSelectors) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingClusterRoleSelector(Predicate predicate) {
      for (V1LabelSelectorBuilder item : clusterRoleSelectors) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withClusterRoleSelectors(List clusterRoleSelectors) {
    if (this.clusterRoleSelectors != null) {
      this._visitables.get("clusterRoleSelectors").clear();
    }
    if (clusterRoleSelectors != null) {
        this.clusterRoleSelectors = new ArrayList();
        for (V1LabelSelector item : clusterRoleSelectors) {
          this.addToClusterRoleSelectors(item);
        }
    } else {
      this.clusterRoleSelectors = null;
    }
    return (A) this;
  }
  
  public A withClusterRoleSelectors(io.kubernetes.client.openapi.models.V1LabelSelector... clusterRoleSelectors) {
    if (this.clusterRoleSelectors != null) {
        this.clusterRoleSelectors.clear();
        _visitables.remove("clusterRoleSelectors");
    }
    if (clusterRoleSelectors != null) {
      for (V1LabelSelector item : clusterRoleSelectors) {
        this.addToClusterRoleSelectors(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasClusterRoleSelectors() {
    return this.clusterRoleSelectors != null && !this.clusterRoleSelectors.isEmpty();
  }
  
  public ClusterRoleSelectorsNested addNewClusterRoleSelector() {
    return new ClusterRoleSelectorsNested(-1, null);
  }
  
  public ClusterRoleSelectorsNested addNewClusterRoleSelectorLike(V1LabelSelector item) {
    return new ClusterRoleSelectorsNested(-1, item);
  }
  
  public ClusterRoleSelectorsNested setNewClusterRoleSelectorLike(int index,V1LabelSelector item) {
    return new ClusterRoleSelectorsNested(index, item);
  }
  
  public ClusterRoleSelectorsNested editClusterRoleSelector(int index) {
    if (clusterRoleSelectors.size() <= index) throw new RuntimeException("Can't edit clusterRoleSelectors. Index exceeds size.");
    return setNewClusterRoleSelectorLike(index, buildClusterRoleSelector(index));
  }
  
  public ClusterRoleSelectorsNested editFirstClusterRoleSelector() {
    if (clusterRoleSelectors.size() == 0) throw new RuntimeException("Can't edit first clusterRoleSelectors. The list is empty.");
    return setNewClusterRoleSelectorLike(0, buildClusterRoleSelector(0));
  }
  
  public ClusterRoleSelectorsNested editLastClusterRoleSelector() {
    int index = clusterRoleSelectors.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last clusterRoleSelectors. The list is empty.");
    return setNewClusterRoleSelectorLike(index, buildClusterRoleSelector(index));
  }
  
  public ClusterRoleSelectorsNested editMatchingClusterRoleSelector(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1LabelSelectorFluent> implements Nested{
    ClusterRoleSelectorsNested(int index,V1LabelSelector item) {
      this.index = index;
      this.builder = new V1LabelSelectorBuilder(this, item);
    }
    V1LabelSelectorBuilder builder;
    int index;
    
    public N and() {
      return (N) V1AggregationRuleFluent.this.setToClusterRoleSelectors(index,builder.build());
    }
    
    public N endClusterRoleSelector() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy