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

io.kubernetes.client.openapi.models.V1beta1MatchResourcesFluent 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.List;
import java.util.Collection;
import java.lang.Object;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class V1beta1MatchResourcesFluent> extends BaseFluent{
  public V1beta1MatchResourcesFluent() {
  }
  
  public V1beta1MatchResourcesFluent(V1beta1MatchResources instance) {
    this.copyInstance(instance);
  }
  private ArrayList excludeResourceRules;
  private String matchPolicy;
  private V1LabelSelectorBuilder namespaceSelector;
  private V1LabelSelectorBuilder objectSelector;
  private ArrayList resourceRules;
  
  protected void copyInstance(V1beta1MatchResources instance) {
    instance = (instance != null ? instance : new V1beta1MatchResources());
    if (instance != null) {
          this.withExcludeResourceRules(instance.getExcludeResourceRules());
          this.withMatchPolicy(instance.getMatchPolicy());
          this.withNamespaceSelector(instance.getNamespaceSelector());
          this.withObjectSelector(instance.getObjectSelector());
          this.withResourceRules(instance.getResourceRules());
        }
  }
  
  public A addToExcludeResourceRules(int index,V1beta1NamedRuleWithOperations item) {
    if (this.excludeResourceRules == null) {this.excludeResourceRules = new ArrayList();}
    V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);
    if (index < 0 || index >= excludeResourceRules.size()) { _visitables.get("excludeResourceRules").add(builder); excludeResourceRules.add(builder); } else { _visitables.get("excludeResourceRules").add(index, builder); excludeResourceRules.add(index, builder);}
    return (A)this;
  }
  
  public A setToExcludeResourceRules(int index,V1beta1NamedRuleWithOperations item) {
    if (this.excludeResourceRules == null) {this.excludeResourceRules = new ArrayList();}
    V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);
    if (index < 0 || index >= excludeResourceRules.size()) { _visitables.get("excludeResourceRules").add(builder); excludeResourceRules.add(builder); } else { _visitables.get("excludeResourceRules").set(index, builder); excludeResourceRules.set(index, builder);}
    return (A)this;
  }
  
  public A addToExcludeResourceRules(io.kubernetes.client.openapi.models.V1beta1NamedRuleWithOperations... items) {
    if (this.excludeResourceRules == null) {this.excludeResourceRules = new ArrayList();}
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("excludeResourceRules").add(builder);this.excludeResourceRules.add(builder);} return (A)this;
  }
  
  public A addAllToExcludeResourceRules(Collection items) {
    if (this.excludeResourceRules == null) {this.excludeResourceRules = new ArrayList();}
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("excludeResourceRules").add(builder);this.excludeResourceRules.add(builder);} return (A)this;
  }
  
  public A removeFromExcludeResourceRules(io.kubernetes.client.openapi.models.V1beta1NamedRuleWithOperations... items) {
    if (this.excludeResourceRules == null) return (A)this;
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("excludeResourceRules").remove(builder); this.excludeResourceRules.remove(builder);} return (A)this;
  }
  
  public A removeAllFromExcludeResourceRules(Collection items) {
    if (this.excludeResourceRules == null) return (A)this;
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("excludeResourceRules").remove(builder); this.excludeResourceRules.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromExcludeResourceRules(Predicate predicate) {
    if (excludeResourceRules == null) return (A) this;
    final Iterator each = excludeResourceRules.iterator();
    final List visitables = _visitables.get("excludeResourceRules");
    while (each.hasNext()) {
      V1beta1NamedRuleWithOperationsBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildExcludeResourceRules() {
    return this.excludeResourceRules != null ? build(excludeResourceRules) : null;
  }
  
  public V1beta1NamedRuleWithOperations buildExcludeResourceRule(int index) {
    return this.excludeResourceRules.get(index).build();
  }
  
  public V1beta1NamedRuleWithOperations buildFirstExcludeResourceRule() {
    return this.excludeResourceRules.get(0).build();
  }
  
  public V1beta1NamedRuleWithOperations buildLastExcludeResourceRule() {
    return this.excludeResourceRules.get(excludeResourceRules.size() - 1).build();
  }
  
  public V1beta1NamedRuleWithOperations buildMatchingExcludeResourceRule(Predicate predicate) {
      for (V1beta1NamedRuleWithOperationsBuilder item : excludeResourceRules) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingExcludeResourceRule(Predicate predicate) {
      for (V1beta1NamedRuleWithOperationsBuilder item : excludeResourceRules) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withExcludeResourceRules(List excludeResourceRules) {
    if (this.excludeResourceRules != null) {
      this._visitables.get("excludeResourceRules").clear();
    }
    if (excludeResourceRules != null) {
        this.excludeResourceRules = new ArrayList();
        for (V1beta1NamedRuleWithOperations item : excludeResourceRules) {
          this.addToExcludeResourceRules(item);
        }
    } else {
      this.excludeResourceRules = null;
    }
    return (A) this;
  }
  
  public A withExcludeResourceRules(io.kubernetes.client.openapi.models.V1beta1NamedRuleWithOperations... excludeResourceRules) {
    if (this.excludeResourceRules != null) {
        this.excludeResourceRules.clear();
        _visitables.remove("excludeResourceRules");
    }
    if (excludeResourceRules != null) {
      for (V1beta1NamedRuleWithOperations item : excludeResourceRules) {
        this.addToExcludeResourceRules(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasExcludeResourceRules() {
    return this.excludeResourceRules != null && !this.excludeResourceRules.isEmpty();
  }
  
  public ExcludeResourceRulesNested addNewExcludeResourceRule() {
    return new ExcludeResourceRulesNested(-1, null);
  }
  
  public ExcludeResourceRulesNested addNewExcludeResourceRuleLike(V1beta1NamedRuleWithOperations item) {
    return new ExcludeResourceRulesNested(-1, item);
  }
  
  public ExcludeResourceRulesNested setNewExcludeResourceRuleLike(int index,V1beta1NamedRuleWithOperations item) {
    return new ExcludeResourceRulesNested(index, item);
  }
  
  public ExcludeResourceRulesNested editExcludeResourceRule(int index) {
    if (excludeResourceRules.size() <= index) throw new RuntimeException("Can't edit excludeResourceRules. Index exceeds size.");
    return setNewExcludeResourceRuleLike(index, buildExcludeResourceRule(index));
  }
  
  public ExcludeResourceRulesNested editFirstExcludeResourceRule() {
    if (excludeResourceRules.size() == 0) throw new RuntimeException("Can't edit first excludeResourceRules. The list is empty.");
    return setNewExcludeResourceRuleLike(0, buildExcludeResourceRule(0));
  }
  
  public ExcludeResourceRulesNested editLastExcludeResourceRule() {
    int index = excludeResourceRules.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last excludeResourceRules. The list is empty.");
    return setNewExcludeResourceRuleLike(index, buildExcludeResourceRule(index));
  }
  
  public ExcludeResourceRulesNested editMatchingExcludeResourceRule(Predicate predicate) {
    int index = -1;
    for (int i=0;i withNewNamespaceSelector() {
    return new NamespaceSelectorNested(null);
  }
  
  public NamespaceSelectorNested withNewNamespaceSelectorLike(V1LabelSelector item) {
    return new NamespaceSelectorNested(item);
  }
  
  public NamespaceSelectorNested editNamespaceSelector() {
    return withNewNamespaceSelectorLike(java.util.Optional.ofNullable(buildNamespaceSelector()).orElse(null));
  }
  
  public NamespaceSelectorNested editOrNewNamespaceSelector() {
    return withNewNamespaceSelectorLike(java.util.Optional.ofNullable(buildNamespaceSelector()).orElse(new V1LabelSelectorBuilder().build()));
  }
  
  public NamespaceSelectorNested editOrNewNamespaceSelectorLike(V1LabelSelector item) {
    return withNewNamespaceSelectorLike(java.util.Optional.ofNullable(buildNamespaceSelector()).orElse(item));
  }
  
  public V1LabelSelector buildObjectSelector() {
    return this.objectSelector != null ? this.objectSelector.build() : null;
  }
  
  public A withObjectSelector(V1LabelSelector objectSelector) {
    this._visitables.remove("objectSelector");
    if (objectSelector != null) {
        this.objectSelector = new V1LabelSelectorBuilder(objectSelector);
        this._visitables.get("objectSelector").add(this.objectSelector);
    } else {
        this.objectSelector = null;
        this._visitables.get("objectSelector").remove(this.objectSelector);
    }
    return (A) this;
  }
  
  public boolean hasObjectSelector() {
    return this.objectSelector != null;
  }
  
  public ObjectSelectorNested withNewObjectSelector() {
    return new ObjectSelectorNested(null);
  }
  
  public ObjectSelectorNested withNewObjectSelectorLike(V1LabelSelector item) {
    return new ObjectSelectorNested(item);
  }
  
  public ObjectSelectorNested editObjectSelector() {
    return withNewObjectSelectorLike(java.util.Optional.ofNullable(buildObjectSelector()).orElse(null));
  }
  
  public ObjectSelectorNested editOrNewObjectSelector() {
    return withNewObjectSelectorLike(java.util.Optional.ofNullable(buildObjectSelector()).orElse(new V1LabelSelectorBuilder().build()));
  }
  
  public ObjectSelectorNested editOrNewObjectSelectorLike(V1LabelSelector item) {
    return withNewObjectSelectorLike(java.util.Optional.ofNullable(buildObjectSelector()).orElse(item));
  }
  
  public A addToResourceRules(int index,V1beta1NamedRuleWithOperations item) {
    if (this.resourceRules == null) {this.resourceRules = new ArrayList();}
    V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);
    if (index < 0 || index >= resourceRules.size()) { _visitables.get("resourceRules").add(builder); resourceRules.add(builder); } else { _visitables.get("resourceRules").add(index, builder); resourceRules.add(index, builder);}
    return (A)this;
  }
  
  public A setToResourceRules(int index,V1beta1NamedRuleWithOperations item) {
    if (this.resourceRules == null) {this.resourceRules = new ArrayList();}
    V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);
    if (index < 0 || index >= resourceRules.size()) { _visitables.get("resourceRules").add(builder); resourceRules.add(builder); } else { _visitables.get("resourceRules").set(index, builder); resourceRules.set(index, builder);}
    return (A)this;
  }
  
  public A addToResourceRules(io.kubernetes.client.openapi.models.V1beta1NamedRuleWithOperations... items) {
    if (this.resourceRules == null) {this.resourceRules = new ArrayList();}
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("resourceRules").add(builder);this.resourceRules.add(builder);} return (A)this;
  }
  
  public A addAllToResourceRules(Collection items) {
    if (this.resourceRules == null) {this.resourceRules = new ArrayList();}
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("resourceRules").add(builder);this.resourceRules.add(builder);} return (A)this;
  }
  
  public A removeFromResourceRules(io.kubernetes.client.openapi.models.V1beta1NamedRuleWithOperations... items) {
    if (this.resourceRules == null) return (A)this;
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("resourceRules").remove(builder); this.resourceRules.remove(builder);} return (A)this;
  }
  
  public A removeAllFromResourceRules(Collection items) {
    if (this.resourceRules == null) return (A)this;
    for (V1beta1NamedRuleWithOperations item : items) {V1beta1NamedRuleWithOperationsBuilder builder = new V1beta1NamedRuleWithOperationsBuilder(item);_visitables.get("resourceRules").remove(builder); this.resourceRules.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromResourceRules(Predicate predicate) {
    if (resourceRules == null) return (A) this;
    final Iterator each = resourceRules.iterator();
    final List visitables = _visitables.get("resourceRules");
    while (each.hasNext()) {
      V1beta1NamedRuleWithOperationsBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildResourceRules() {
    return this.resourceRules != null ? build(resourceRules) : null;
  }
  
  public V1beta1NamedRuleWithOperations buildResourceRule(int index) {
    return this.resourceRules.get(index).build();
  }
  
  public V1beta1NamedRuleWithOperations buildFirstResourceRule() {
    return this.resourceRules.get(0).build();
  }
  
  public V1beta1NamedRuleWithOperations buildLastResourceRule() {
    return this.resourceRules.get(resourceRules.size() - 1).build();
  }
  
  public V1beta1NamedRuleWithOperations buildMatchingResourceRule(Predicate predicate) {
      for (V1beta1NamedRuleWithOperationsBuilder item : resourceRules) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingResourceRule(Predicate predicate) {
      for (V1beta1NamedRuleWithOperationsBuilder item : resourceRules) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withResourceRules(List resourceRules) {
    if (this.resourceRules != null) {
      this._visitables.get("resourceRules").clear();
    }
    if (resourceRules != null) {
        this.resourceRules = new ArrayList();
        for (V1beta1NamedRuleWithOperations item : resourceRules) {
          this.addToResourceRules(item);
        }
    } else {
      this.resourceRules = null;
    }
    return (A) this;
  }
  
  public A withResourceRules(io.kubernetes.client.openapi.models.V1beta1NamedRuleWithOperations... resourceRules) {
    if (this.resourceRules != null) {
        this.resourceRules.clear();
        _visitables.remove("resourceRules");
    }
    if (resourceRules != null) {
      for (V1beta1NamedRuleWithOperations item : resourceRules) {
        this.addToResourceRules(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasResourceRules() {
    return this.resourceRules != null && !this.resourceRules.isEmpty();
  }
  
  public ResourceRulesNested addNewResourceRule() {
    return new ResourceRulesNested(-1, null);
  }
  
  public ResourceRulesNested addNewResourceRuleLike(V1beta1NamedRuleWithOperations item) {
    return new ResourceRulesNested(-1, item);
  }
  
  public ResourceRulesNested setNewResourceRuleLike(int index,V1beta1NamedRuleWithOperations item) {
    return new ResourceRulesNested(index, item);
  }
  
  public ResourceRulesNested editResourceRule(int index) {
    if (resourceRules.size() <= index) throw new RuntimeException("Can't edit resourceRules. Index exceeds size.");
    return setNewResourceRuleLike(index, buildResourceRule(index));
  }
  
  public ResourceRulesNested editFirstResourceRule() {
    if (resourceRules.size() == 0) throw new RuntimeException("Can't edit first resourceRules. The list is empty.");
    return setNewResourceRuleLike(0, buildResourceRule(0));
  }
  
  public ResourceRulesNested editLastResourceRule() {
    int index = resourceRules.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last resourceRules. The list is empty.");
    return setNewResourceRuleLike(index, buildResourceRule(index));
  }
  
  public ResourceRulesNested editMatchingResourceRule(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1beta1NamedRuleWithOperationsFluent> implements Nested{
    ExcludeResourceRulesNested(int index,V1beta1NamedRuleWithOperations item) {
      this.index = index;
      this.builder = new V1beta1NamedRuleWithOperationsBuilder(this, item);
    }
    V1beta1NamedRuleWithOperationsBuilder builder;
    int index;
    
    public N and() {
      return (N) V1beta1MatchResourcesFluent.this.setToExcludeResourceRules(index,builder.build());
    }
    
    public N endExcludeResourceRule() {
      return and();
    }
    
  
  }
  public class NamespaceSelectorNested extends V1LabelSelectorFluent> implements Nested{
    NamespaceSelectorNested(V1LabelSelector item) {
      this.builder = new V1LabelSelectorBuilder(this, item);
    }
    V1LabelSelectorBuilder builder;
    
    public N and() {
      return (N) V1beta1MatchResourcesFluent.this.withNamespaceSelector(builder.build());
    }
    
    public N endNamespaceSelector() {
      return and();
    }
    
  
  }
  public class ObjectSelectorNested extends V1LabelSelectorFluent> implements Nested{
    ObjectSelectorNested(V1LabelSelector item) {
      this.builder = new V1LabelSelectorBuilder(this, item);
    }
    V1LabelSelectorBuilder builder;
    
    public N and() {
      return (N) V1beta1MatchResourcesFluent.this.withObjectSelector(builder.build());
    }
    
    public N endObjectSelector() {
      return and();
    }
    
  
  }
  public class ResourceRulesNested extends V1beta1NamedRuleWithOperationsFluent> implements Nested{
    ResourceRulesNested(int index,V1beta1NamedRuleWithOperations item) {
      this.index = index;
      this.builder = new V1beta1NamedRuleWithOperationsBuilder(this, item);
    }
    V1beta1NamedRuleWithOperationsBuilder builder;
    int index;
    
    public N and() {
      return (N) V1beta1MatchResourcesFluent.this.setToResourceRules(index,builder.build());
    }
    
    public N endResourceRule() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy