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

io.fabric8.openshift.api.model.machine.v1beta1.MachineHealthCheckSpecFluent Maven / Gradle / Ivy

The newest version!
package io.fabric8.openshift.api.model.machine.v1beta1;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import io.fabric8.kubernetes.api.model.IntOrString;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.fabric8.kubernetes.api.model.IntOrStringBuilder;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.model.ObjectReference;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import io.fabric8.kubernetes.api.model.LabelSelectorBuilder;
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.Duration;
import io.fabric8.kubernetes.api.model.IntOrStringFluent;
import io.fabric8.kubernetes.api.model.ObjectReferenceFluent;
import io.fabric8.kubernetes.api.model.ObjectReferenceBuilder;
import java.util.Collection;
import java.lang.Object;
import io.fabric8.kubernetes.api.model.LabelSelectorFluent;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class MachineHealthCheckSpecFluent> extends BaseFluent{
  public MachineHealthCheckSpecFluent() {
  }
  
  public MachineHealthCheckSpecFluent(MachineHealthCheckSpec instance) {
    this.copyInstance(instance);
  }
  private IntOrStringBuilder maxUnhealthy;
  private Duration nodeStartupTimeout;
  private ObjectReferenceBuilder remediationTemplate;
  private LabelSelectorBuilder selector;
  private ArrayList unhealthyConditions = new ArrayList();
  private Map additionalProperties;
  
  protected void copyInstance(MachineHealthCheckSpec instance) {
    instance = (instance != null ? instance : new MachineHealthCheckSpec());
    if (instance != null) {
          this.withMaxUnhealthy(instance.getMaxUnhealthy());
          this.withNodeStartupTimeout(instance.getNodeStartupTimeout());
          this.withRemediationTemplate(instance.getRemediationTemplate());
          this.withSelector(instance.getSelector());
          this.withUnhealthyConditions(instance.getUnhealthyConditions());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  public IntOrString buildMaxUnhealthy() {
    return this.maxUnhealthy != null ? this.maxUnhealthy.build() : null;
  }
  
  public A withMaxUnhealthy(IntOrString maxUnhealthy) {
    this._visitables.remove("maxUnhealthy");
    if (maxUnhealthy != null) {
        this.maxUnhealthy = new IntOrStringBuilder(maxUnhealthy);
        this._visitables.get("maxUnhealthy").add(this.maxUnhealthy);
    } else {
        this.maxUnhealthy = null;
        this._visitables.get("maxUnhealthy").remove(this.maxUnhealthy);
    }
    return (A) this;
  }
  
  public boolean hasMaxUnhealthy() {
    return this.maxUnhealthy != null;
  }
  
  public A withNewMaxUnhealthy(Object value) {
    return (A)withMaxUnhealthy(new IntOrString(value));
  }
  
  public MaxUnhealthyNested withNewMaxUnhealthy() {
    return new MaxUnhealthyNested(null);
  }
  
  public MaxUnhealthyNested withNewMaxUnhealthyLike(IntOrString item) {
    return new MaxUnhealthyNested(item);
  }
  
  public MaxUnhealthyNested editMaxUnhealthy() {
    return withNewMaxUnhealthyLike(java.util.Optional.ofNullable(buildMaxUnhealthy()).orElse(null));
  }
  
  public MaxUnhealthyNested editOrNewMaxUnhealthy() {
    return withNewMaxUnhealthyLike(java.util.Optional.ofNullable(buildMaxUnhealthy()).orElse(new IntOrStringBuilder().build()));
  }
  
  public MaxUnhealthyNested editOrNewMaxUnhealthyLike(IntOrString item) {
    return withNewMaxUnhealthyLike(java.util.Optional.ofNullable(buildMaxUnhealthy()).orElse(item));
  }
  
  public Duration getNodeStartupTimeout() {
    return this.nodeStartupTimeout;
  }
  
  public A withNodeStartupTimeout(Duration nodeStartupTimeout) {
    this.nodeStartupTimeout = nodeStartupTimeout;
    return (A) this;
  }
  
  public boolean hasNodeStartupTimeout() {
    return this.nodeStartupTimeout != null;
  }
  
  public ObjectReference buildRemediationTemplate() {
    return this.remediationTemplate != null ? this.remediationTemplate.build() : null;
  }
  
  public A withRemediationTemplate(ObjectReference remediationTemplate) {
    this._visitables.remove("remediationTemplate");
    if (remediationTemplate != null) {
        this.remediationTemplate = new ObjectReferenceBuilder(remediationTemplate);
        this._visitables.get("remediationTemplate").add(this.remediationTemplate);
    } else {
        this.remediationTemplate = null;
        this._visitables.get("remediationTemplate").remove(this.remediationTemplate);
    }
    return (A) this;
  }
  
  public boolean hasRemediationTemplate() {
    return this.remediationTemplate != null;
  }
  
  public RemediationTemplateNested withNewRemediationTemplate() {
    return new RemediationTemplateNested(null);
  }
  
  public RemediationTemplateNested withNewRemediationTemplateLike(ObjectReference item) {
    return new RemediationTemplateNested(item);
  }
  
  public RemediationTemplateNested editRemediationTemplate() {
    return withNewRemediationTemplateLike(java.util.Optional.ofNullable(buildRemediationTemplate()).orElse(null));
  }
  
  public RemediationTemplateNested editOrNewRemediationTemplate() {
    return withNewRemediationTemplateLike(java.util.Optional.ofNullable(buildRemediationTemplate()).orElse(new ObjectReferenceBuilder().build()));
  }
  
  public RemediationTemplateNested editOrNewRemediationTemplateLike(ObjectReference item) {
    return withNewRemediationTemplateLike(java.util.Optional.ofNullable(buildRemediationTemplate()).orElse(item));
  }
  
  public LabelSelector buildSelector() {
    return this.selector != null ? this.selector.build() : null;
  }
  
  public A withSelector(LabelSelector selector) {
    this._visitables.remove("selector");
    if (selector != null) {
        this.selector = new LabelSelectorBuilder(selector);
        this._visitables.get("selector").add(this.selector);
    } else {
        this.selector = null;
        this._visitables.get("selector").remove(this.selector);
    }
    return (A) this;
  }
  
  public boolean hasSelector() {
    return this.selector != null;
  }
  
  public SelectorNested withNewSelector() {
    return new SelectorNested(null);
  }
  
  public SelectorNested withNewSelectorLike(LabelSelector item) {
    return new SelectorNested(item);
  }
  
  public SelectorNested editSelector() {
    return withNewSelectorLike(java.util.Optional.ofNullable(buildSelector()).orElse(null));
  }
  
  public SelectorNested editOrNewSelector() {
    return withNewSelectorLike(java.util.Optional.ofNullable(buildSelector()).orElse(new LabelSelectorBuilder().build()));
  }
  
  public SelectorNested editOrNewSelectorLike(LabelSelector item) {
    return withNewSelectorLike(java.util.Optional.ofNullable(buildSelector()).orElse(item));
  }
  
  public A addToUnhealthyConditions(int index,UnhealthyCondition item) {
    if (this.unhealthyConditions == null) {this.unhealthyConditions = new ArrayList();}
    UnhealthyConditionBuilder builder = new UnhealthyConditionBuilder(item);
    if (index < 0 || index >= unhealthyConditions.size()) { _visitables.get("unhealthyConditions").add(builder); unhealthyConditions.add(builder); } else { _visitables.get("unhealthyConditions").add(index, builder); unhealthyConditions.add(index, builder);}
    return (A)this;
  }
  
  public A setToUnhealthyConditions(int index,UnhealthyCondition item) {
    if (this.unhealthyConditions == null) {this.unhealthyConditions = new ArrayList();}
    UnhealthyConditionBuilder builder = new UnhealthyConditionBuilder(item);
    if (index < 0 || index >= unhealthyConditions.size()) { _visitables.get("unhealthyConditions").add(builder); unhealthyConditions.add(builder); } else { _visitables.get("unhealthyConditions").set(index, builder); unhealthyConditions.set(index, builder);}
    return (A)this;
  }
  
  public A addToUnhealthyConditions(io.fabric8.openshift.api.model.machine.v1beta1.UnhealthyCondition... items) {
    if (this.unhealthyConditions == null) {this.unhealthyConditions = new ArrayList();}
    for (UnhealthyCondition item : items) {UnhealthyConditionBuilder builder = new UnhealthyConditionBuilder(item);_visitables.get("unhealthyConditions").add(builder);this.unhealthyConditions.add(builder);} return (A)this;
  }
  
  public A addAllToUnhealthyConditions(Collection items) {
    if (this.unhealthyConditions == null) {this.unhealthyConditions = new ArrayList();}
    for (UnhealthyCondition item : items) {UnhealthyConditionBuilder builder = new UnhealthyConditionBuilder(item);_visitables.get("unhealthyConditions").add(builder);this.unhealthyConditions.add(builder);} return (A)this;
  }
  
  public A removeFromUnhealthyConditions(io.fabric8.openshift.api.model.machine.v1beta1.UnhealthyCondition... items) {
    if (this.unhealthyConditions == null) return (A)this;
    for (UnhealthyCondition item : items) {UnhealthyConditionBuilder builder = new UnhealthyConditionBuilder(item);_visitables.get("unhealthyConditions").remove(builder); this.unhealthyConditions.remove(builder);} return (A)this;
  }
  
  public A removeAllFromUnhealthyConditions(Collection items) {
    if (this.unhealthyConditions == null) return (A)this;
    for (UnhealthyCondition item : items) {UnhealthyConditionBuilder builder = new UnhealthyConditionBuilder(item);_visitables.get("unhealthyConditions").remove(builder); this.unhealthyConditions.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromUnhealthyConditions(Predicate predicate) {
    if (unhealthyConditions == null) return (A) this;
    final Iterator each = unhealthyConditions.iterator();
    final List visitables = _visitables.get("unhealthyConditions");
    while (each.hasNext()) {
      UnhealthyConditionBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildUnhealthyConditions() {
    return this.unhealthyConditions != null ? build(unhealthyConditions) : null;
  }
  
  public UnhealthyCondition buildUnhealthyCondition(int index) {
    return this.unhealthyConditions.get(index).build();
  }
  
  public UnhealthyCondition buildFirstUnhealthyCondition() {
    return this.unhealthyConditions.get(0).build();
  }
  
  public UnhealthyCondition buildLastUnhealthyCondition() {
    return this.unhealthyConditions.get(unhealthyConditions.size() - 1).build();
  }
  
  public UnhealthyCondition buildMatchingUnhealthyCondition(Predicate predicate) {
      for (UnhealthyConditionBuilder item : unhealthyConditions) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingUnhealthyCondition(Predicate predicate) {
      for (UnhealthyConditionBuilder item : unhealthyConditions) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withUnhealthyConditions(List unhealthyConditions) {
    if (this.unhealthyConditions != null) {
      this._visitables.get("unhealthyConditions").clear();
    }
    if (unhealthyConditions != null) {
        this.unhealthyConditions = new ArrayList();
        for (UnhealthyCondition item : unhealthyConditions) {
          this.addToUnhealthyConditions(item);
        }
    } else {
      this.unhealthyConditions = null;
    }
    return (A) this;
  }
  
  public A withUnhealthyConditions(io.fabric8.openshift.api.model.machine.v1beta1.UnhealthyCondition... unhealthyConditions) {
    if (this.unhealthyConditions != null) {
        this.unhealthyConditions.clear();
        _visitables.remove("unhealthyConditions");
    }
    if (unhealthyConditions != null) {
      for (UnhealthyCondition item : unhealthyConditions) {
        this.addToUnhealthyConditions(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasUnhealthyConditions() {
    return this.unhealthyConditions != null && !this.unhealthyConditions.isEmpty();
  }
  
  public UnhealthyConditionsNested addNewUnhealthyCondition() {
    return new UnhealthyConditionsNested(-1, null);
  }
  
  public UnhealthyConditionsNested addNewUnhealthyConditionLike(UnhealthyCondition item) {
    return new UnhealthyConditionsNested(-1, item);
  }
  
  public UnhealthyConditionsNested setNewUnhealthyConditionLike(int index,UnhealthyCondition item) {
    return new UnhealthyConditionsNested(index, item);
  }
  
  public UnhealthyConditionsNested editUnhealthyCondition(int index) {
    if (unhealthyConditions.size() <= index) throw new RuntimeException("Can't edit unhealthyConditions. Index exceeds size.");
    return setNewUnhealthyConditionLike(index, buildUnhealthyCondition(index));
  }
  
  public UnhealthyConditionsNested editFirstUnhealthyCondition() {
    if (unhealthyConditions.size() == 0) throw new RuntimeException("Can't edit first unhealthyConditions. The list is empty.");
    return setNewUnhealthyConditionLike(0, buildUnhealthyCondition(0));
  }
  
  public UnhealthyConditionsNested editLastUnhealthyCondition() {
    int index = unhealthyConditions.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last unhealthyConditions. The list is empty.");
    return setNewUnhealthyConditionLike(index, buildUnhealthyCondition(index));
  }
  
  public UnhealthyConditionsNested editMatchingUnhealthyCondition(Predicate predicate) {
    int index = -1;
    for (int i=0;i map) {
    if(this.additionalProperties == null && map != null) { this.additionalProperties = new LinkedHashMap(); }
    if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
  }
  
  public A removeFromAdditionalProperties(String key) {
    if(this.additionalProperties == null) { return (A) this; }
    if(key != null && this.additionalProperties != null) {this.additionalProperties.remove(key);} return (A)this;
  }
  
  public A removeFromAdditionalProperties(Map map) {
    if(this.additionalProperties == null) { return (A) this; }
    if(map != null) { for(Object key : map.keySet()) {if (this.additionalProperties != null){this.additionalProperties.remove(key);}}} return (A)this;
  }
  
  public Map getAdditionalProperties() {
    return this.additionalProperties;
  }
  
  public A withAdditionalProperties(Map additionalProperties) {
    if (additionalProperties == null) {
      this.additionalProperties = null;
    } else {
      this.additionalProperties = new LinkedHashMap(additionalProperties);
    }
    return (A) this;
  }
  
  public boolean hasAdditionalProperties() {
    return this.additionalProperties != null;
  }
  
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    MachineHealthCheckSpecFluent that = (MachineHealthCheckSpecFluent) o;
    if (!java.util.Objects.equals(maxUnhealthy, that.maxUnhealthy)) return false;
    if (!java.util.Objects.equals(nodeStartupTimeout, that.nodeStartupTimeout)) return false;
    if (!java.util.Objects.equals(remediationTemplate, that.remediationTemplate)) return false;
    if (!java.util.Objects.equals(selector, that.selector)) return false;
    if (!java.util.Objects.equals(unhealthyConditions, that.unhealthyConditions)) return false;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(maxUnhealthy,  nodeStartupTimeout,  remediationTemplate,  selector,  unhealthyConditions,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (maxUnhealthy != null) { sb.append("maxUnhealthy:"); sb.append(maxUnhealthy + ","); }
    if (nodeStartupTimeout != null) { sb.append("nodeStartupTimeout:"); sb.append(nodeStartupTimeout + ","); }
    if (remediationTemplate != null) { sb.append("remediationTemplate:"); sb.append(remediationTemplate + ","); }
    if (selector != null) { sb.append("selector:"); sb.append(selector + ","); }
    if (unhealthyConditions != null && !unhealthyConditions.isEmpty()) { sb.append("unhealthyConditions:"); sb.append(unhealthyConditions + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class MaxUnhealthyNested extends IntOrStringFluent> implements Nested{
    MaxUnhealthyNested(IntOrString item) {
      this.builder = new IntOrStringBuilder(this, item);
    }
    IntOrStringBuilder builder;
    
    public N and() {
      return (N) MachineHealthCheckSpecFluent.this.withMaxUnhealthy(builder.build());
    }
    
    public N endMaxUnhealthy() {
      return and();
    }
    
  
  }
  public class RemediationTemplateNested extends ObjectReferenceFluent> implements Nested{
    RemediationTemplateNested(ObjectReference item) {
      this.builder = new ObjectReferenceBuilder(this, item);
    }
    ObjectReferenceBuilder builder;
    
    public N and() {
      return (N) MachineHealthCheckSpecFluent.this.withRemediationTemplate(builder.build());
    }
    
    public N endRemediationTemplate() {
      return and();
    }
    
  
  }
  public class SelectorNested extends LabelSelectorFluent> implements Nested{
    SelectorNested(LabelSelector item) {
      this.builder = new LabelSelectorBuilder(this, item);
    }
    LabelSelectorBuilder builder;
    
    public N and() {
      return (N) MachineHealthCheckSpecFluent.this.withSelector(builder.build());
    }
    
    public N endSelector() {
      return and();
    }
    
  
  }
  public class UnhealthyConditionsNested extends UnhealthyConditionFluent> implements Nested{
    UnhealthyConditionsNested(int index,UnhealthyCondition item) {
      this.index = index;
      this.builder = new UnhealthyConditionBuilder(this, item);
    }
    UnhealthyConditionBuilder builder;
    int index;
    
    public N and() {
      return (N) MachineHealthCheckSpecFluent.this.setToUnhealthyConditions(index,builder.build());
    }
    
    public N endUnhealthyCondition() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy