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

io.kubernetes.client.openapi.models.V1PodFailurePolicyRuleFluent 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 V1PodFailurePolicyRuleFluent> extends BaseFluent{
  public V1PodFailurePolicyRuleFluent() {
  }
  
  public V1PodFailurePolicyRuleFluent(V1PodFailurePolicyRule instance) {
    this.copyInstance(instance);
  }
  private String action;
  private V1PodFailurePolicyOnExitCodesRequirementBuilder onExitCodes;
  private ArrayList onPodConditions;
  
  protected void copyInstance(V1PodFailurePolicyRule instance) {
    instance = (instance != null ? instance : new V1PodFailurePolicyRule());
    if (instance != null) {
          this.withAction(instance.getAction());
          this.withOnExitCodes(instance.getOnExitCodes());
          this.withOnPodConditions(instance.getOnPodConditions());
        }
  }
  
  public String getAction() {
    return this.action;
  }
  
  public A withAction(String action) {
    this.action = action;
    return (A) this;
  }
  
  public boolean hasAction() {
    return this.action != null;
  }
  
  public V1PodFailurePolicyOnExitCodesRequirement buildOnExitCodes() {
    return this.onExitCodes != null ? this.onExitCodes.build() : null;
  }
  
  public A withOnExitCodes(V1PodFailurePolicyOnExitCodesRequirement onExitCodes) {
    this._visitables.remove("onExitCodes");
    if (onExitCodes != null) {
        this.onExitCodes = new V1PodFailurePolicyOnExitCodesRequirementBuilder(onExitCodes);
        this._visitables.get("onExitCodes").add(this.onExitCodes);
    } else {
        this.onExitCodes = null;
        this._visitables.get("onExitCodes").remove(this.onExitCodes);
    }
    return (A) this;
  }
  
  public boolean hasOnExitCodes() {
    return this.onExitCodes != null;
  }
  
  public OnExitCodesNested withNewOnExitCodes() {
    return new OnExitCodesNested(null);
  }
  
  public OnExitCodesNested withNewOnExitCodesLike(V1PodFailurePolicyOnExitCodesRequirement item) {
    return new OnExitCodesNested(item);
  }
  
  public OnExitCodesNested editOnExitCodes() {
    return withNewOnExitCodesLike(java.util.Optional.ofNullable(buildOnExitCodes()).orElse(null));
  }
  
  public OnExitCodesNested editOrNewOnExitCodes() {
    return withNewOnExitCodesLike(java.util.Optional.ofNullable(buildOnExitCodes()).orElse(new V1PodFailurePolicyOnExitCodesRequirementBuilder().build()));
  }
  
  public OnExitCodesNested editOrNewOnExitCodesLike(V1PodFailurePolicyOnExitCodesRequirement item) {
    return withNewOnExitCodesLike(java.util.Optional.ofNullable(buildOnExitCodes()).orElse(item));
  }
  
  public A addToOnPodConditions(int index,V1PodFailurePolicyOnPodConditionsPattern item) {
    if (this.onPodConditions == null) {this.onPodConditions = new ArrayList();}
    V1PodFailurePolicyOnPodConditionsPatternBuilder builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(item);
    if (index < 0 || index >= onPodConditions.size()) { _visitables.get("onPodConditions").add(builder); onPodConditions.add(builder); } else { _visitables.get("onPodConditions").add(index, builder); onPodConditions.add(index, builder);}
    return (A)this;
  }
  
  public A setToOnPodConditions(int index,V1PodFailurePolicyOnPodConditionsPattern item) {
    if (this.onPodConditions == null) {this.onPodConditions = new ArrayList();}
    V1PodFailurePolicyOnPodConditionsPatternBuilder builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(item);
    if (index < 0 || index >= onPodConditions.size()) { _visitables.get("onPodConditions").add(builder); onPodConditions.add(builder); } else { _visitables.get("onPodConditions").set(index, builder); onPodConditions.set(index, builder);}
    return (A)this;
  }
  
  public A addToOnPodConditions(io.kubernetes.client.openapi.models.V1PodFailurePolicyOnPodConditionsPattern... items) {
    if (this.onPodConditions == null) {this.onPodConditions = new ArrayList();}
    for (V1PodFailurePolicyOnPodConditionsPattern item : items) {V1PodFailurePolicyOnPodConditionsPatternBuilder builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(item);_visitables.get("onPodConditions").add(builder);this.onPodConditions.add(builder);} return (A)this;
  }
  
  public A addAllToOnPodConditions(Collection items) {
    if (this.onPodConditions == null) {this.onPodConditions = new ArrayList();}
    for (V1PodFailurePolicyOnPodConditionsPattern item : items) {V1PodFailurePolicyOnPodConditionsPatternBuilder builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(item);_visitables.get("onPodConditions").add(builder);this.onPodConditions.add(builder);} return (A)this;
  }
  
  public A removeFromOnPodConditions(io.kubernetes.client.openapi.models.V1PodFailurePolicyOnPodConditionsPattern... items) {
    if (this.onPodConditions == null) return (A)this;
    for (V1PodFailurePolicyOnPodConditionsPattern item : items) {V1PodFailurePolicyOnPodConditionsPatternBuilder builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(item);_visitables.get("onPodConditions").remove(builder); this.onPodConditions.remove(builder);} return (A)this;
  }
  
  public A removeAllFromOnPodConditions(Collection items) {
    if (this.onPodConditions == null) return (A)this;
    for (V1PodFailurePolicyOnPodConditionsPattern item : items) {V1PodFailurePolicyOnPodConditionsPatternBuilder builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(item);_visitables.get("onPodConditions").remove(builder); this.onPodConditions.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromOnPodConditions(Predicate predicate) {
    if (onPodConditions == null) return (A) this;
    final Iterator each = onPodConditions.iterator();
    final List visitables = _visitables.get("onPodConditions");
    while (each.hasNext()) {
      V1PodFailurePolicyOnPodConditionsPatternBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildOnPodConditions() {
    return this.onPodConditions != null ? build(onPodConditions) : null;
  }
  
  public V1PodFailurePolicyOnPodConditionsPattern buildOnPodCondition(int index) {
    return this.onPodConditions.get(index).build();
  }
  
  public V1PodFailurePolicyOnPodConditionsPattern buildFirstOnPodCondition() {
    return this.onPodConditions.get(0).build();
  }
  
  public V1PodFailurePolicyOnPodConditionsPattern buildLastOnPodCondition() {
    return this.onPodConditions.get(onPodConditions.size() - 1).build();
  }
  
  public V1PodFailurePolicyOnPodConditionsPattern buildMatchingOnPodCondition(Predicate predicate) {
      for (V1PodFailurePolicyOnPodConditionsPatternBuilder item : onPodConditions) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingOnPodCondition(Predicate predicate) {
      for (V1PodFailurePolicyOnPodConditionsPatternBuilder item : onPodConditions) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withOnPodConditions(List onPodConditions) {
    if (this.onPodConditions != null) {
      this._visitables.get("onPodConditions").clear();
    }
    if (onPodConditions != null) {
        this.onPodConditions = new ArrayList();
        for (V1PodFailurePolicyOnPodConditionsPattern item : onPodConditions) {
          this.addToOnPodConditions(item);
        }
    } else {
      this.onPodConditions = null;
    }
    return (A) this;
  }
  
  public A withOnPodConditions(io.kubernetes.client.openapi.models.V1PodFailurePolicyOnPodConditionsPattern... onPodConditions) {
    if (this.onPodConditions != null) {
        this.onPodConditions.clear();
        _visitables.remove("onPodConditions");
    }
    if (onPodConditions != null) {
      for (V1PodFailurePolicyOnPodConditionsPattern item : onPodConditions) {
        this.addToOnPodConditions(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasOnPodConditions() {
    return this.onPodConditions != null && !this.onPodConditions.isEmpty();
  }
  
  public OnPodConditionsNested addNewOnPodCondition() {
    return new OnPodConditionsNested(-1, null);
  }
  
  public OnPodConditionsNested addNewOnPodConditionLike(V1PodFailurePolicyOnPodConditionsPattern item) {
    return new OnPodConditionsNested(-1, item);
  }
  
  public OnPodConditionsNested setNewOnPodConditionLike(int index,V1PodFailurePolicyOnPodConditionsPattern item) {
    return new OnPodConditionsNested(index, item);
  }
  
  public OnPodConditionsNested editOnPodCondition(int index) {
    if (onPodConditions.size() <= index) throw new RuntimeException("Can't edit onPodConditions. Index exceeds size.");
    return setNewOnPodConditionLike(index, buildOnPodCondition(index));
  }
  
  public OnPodConditionsNested editFirstOnPodCondition() {
    if (onPodConditions.size() == 0) throw new RuntimeException("Can't edit first onPodConditions. The list is empty.");
    return setNewOnPodConditionLike(0, buildOnPodCondition(0));
  }
  
  public OnPodConditionsNested editLastOnPodCondition() {
    int index = onPodConditions.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last onPodConditions. The list is empty.");
    return setNewOnPodConditionLike(index, buildOnPodCondition(index));
  }
  
  public OnPodConditionsNested editMatchingOnPodCondition(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1PodFailurePolicyOnExitCodesRequirementFluent> implements Nested{
    OnExitCodesNested(V1PodFailurePolicyOnExitCodesRequirement item) {
      this.builder = new V1PodFailurePolicyOnExitCodesRequirementBuilder(this, item);
    }
    V1PodFailurePolicyOnExitCodesRequirementBuilder builder;
    
    public N and() {
      return (N) V1PodFailurePolicyRuleFluent.this.withOnExitCodes(builder.build());
    }
    
    public N endOnExitCodes() {
      return and();
    }
    
  
  }
  public class OnPodConditionsNested extends V1PodFailurePolicyOnPodConditionsPatternFluent> implements Nested{
    OnPodConditionsNested(int index,V1PodFailurePolicyOnPodConditionsPattern item) {
      this.index = index;
      this.builder = new V1PodFailurePolicyOnPodConditionsPatternBuilder(this, item);
    }
    V1PodFailurePolicyOnPodConditionsPatternBuilder builder;
    int index;
    
    public N and() {
      return (N) V1PodFailurePolicyRuleFluent.this.setToOnPodConditions(index,builder.build());
    }
    
    public N endOnPodCondition() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy