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

io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HorizontalPodAutoscalerSpecFluent Maven / Gradle / Ivy

The newest version!
package io.fabric8.kubernetes.api.model.autoscaling.v2beta2;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Integer;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class HorizontalPodAutoscalerSpecFluent> extends BaseFluent{
  public HorizontalPodAutoscalerSpecFluent() {
  }
  
  public HorizontalPodAutoscalerSpecFluent(HorizontalPodAutoscalerSpec instance) {
    this.copyInstance(instance);
  }
  private HorizontalPodAutoscalerBehaviorBuilder behavior;
  private Integer maxReplicas;
  private ArrayList metrics = new ArrayList();
  private Integer minReplicas;
  private CrossVersionObjectReferenceBuilder scaleTargetRef;
  private Map additionalProperties;
  
  protected void copyInstance(HorizontalPodAutoscalerSpec instance) {
    instance = (instance != null ? instance : new HorizontalPodAutoscalerSpec());
    if (instance != null) {
          this.withBehavior(instance.getBehavior());
          this.withMaxReplicas(instance.getMaxReplicas());
          this.withMetrics(instance.getMetrics());
          this.withMinReplicas(instance.getMinReplicas());
          this.withScaleTargetRef(instance.getScaleTargetRef());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  public HorizontalPodAutoscalerBehavior buildBehavior() {
    return this.behavior != null ? this.behavior.build() : null;
  }
  
  public A withBehavior(HorizontalPodAutoscalerBehavior behavior) {
    this._visitables.remove("behavior");
    if (behavior != null) {
        this.behavior = new HorizontalPodAutoscalerBehaviorBuilder(behavior);
        this._visitables.get("behavior").add(this.behavior);
    } else {
        this.behavior = null;
        this._visitables.get("behavior").remove(this.behavior);
    }
    return (A) this;
  }
  
  public boolean hasBehavior() {
    return this.behavior != null;
  }
  
  public BehaviorNested withNewBehavior() {
    return new BehaviorNested(null);
  }
  
  public BehaviorNested withNewBehaviorLike(HorizontalPodAutoscalerBehavior item) {
    return new BehaviorNested(item);
  }
  
  public BehaviorNested editBehavior() {
    return withNewBehaviorLike(java.util.Optional.ofNullable(buildBehavior()).orElse(null));
  }
  
  public BehaviorNested editOrNewBehavior() {
    return withNewBehaviorLike(java.util.Optional.ofNullable(buildBehavior()).orElse(new HorizontalPodAutoscalerBehaviorBuilder().build()));
  }
  
  public BehaviorNested editOrNewBehaviorLike(HorizontalPodAutoscalerBehavior item) {
    return withNewBehaviorLike(java.util.Optional.ofNullable(buildBehavior()).orElse(item));
  }
  
  public Integer getMaxReplicas() {
    return this.maxReplicas;
  }
  
  public A withMaxReplicas(Integer maxReplicas) {
    this.maxReplicas = maxReplicas;
    return (A) this;
  }
  
  public boolean hasMaxReplicas() {
    return this.maxReplicas != null;
  }
  
  public A addToMetrics(int index,MetricSpec item) {
    if (this.metrics == null) {this.metrics = new ArrayList();}
    MetricSpecBuilder builder = new MetricSpecBuilder(item);
    if (index < 0 || index >= metrics.size()) { _visitables.get("metrics").add(builder); metrics.add(builder); } else { _visitables.get("metrics").add(index, builder); metrics.add(index, builder);}
    return (A)this;
  }
  
  public A setToMetrics(int index,MetricSpec item) {
    if (this.metrics == null) {this.metrics = new ArrayList();}
    MetricSpecBuilder builder = new MetricSpecBuilder(item);
    if (index < 0 || index >= metrics.size()) { _visitables.get("metrics").add(builder); metrics.add(builder); } else { _visitables.get("metrics").set(index, builder); metrics.set(index, builder);}
    return (A)this;
  }
  
  public A addToMetrics(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.MetricSpec... items) {
    if (this.metrics == null) {this.metrics = new ArrayList();}
    for (MetricSpec item : items) {MetricSpecBuilder builder = new MetricSpecBuilder(item);_visitables.get("metrics").add(builder);this.metrics.add(builder);} return (A)this;
  }
  
  public A addAllToMetrics(Collection items) {
    if (this.metrics == null) {this.metrics = new ArrayList();}
    for (MetricSpec item : items) {MetricSpecBuilder builder = new MetricSpecBuilder(item);_visitables.get("metrics").add(builder);this.metrics.add(builder);} return (A)this;
  }
  
  public A removeFromMetrics(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.MetricSpec... items) {
    if (this.metrics == null) return (A)this;
    for (MetricSpec item : items) {MetricSpecBuilder builder = new MetricSpecBuilder(item);_visitables.get("metrics").remove(builder); this.metrics.remove(builder);} return (A)this;
  }
  
  public A removeAllFromMetrics(Collection items) {
    if (this.metrics == null) return (A)this;
    for (MetricSpec item : items) {MetricSpecBuilder builder = new MetricSpecBuilder(item);_visitables.get("metrics").remove(builder); this.metrics.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromMetrics(Predicate predicate) {
    if (metrics == null) return (A) this;
    final Iterator each = metrics.iterator();
    final List visitables = _visitables.get("metrics");
    while (each.hasNext()) {
      MetricSpecBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildMetrics() {
    return this.metrics != null ? build(metrics) : null;
  }
  
  public MetricSpec buildMetric(int index) {
    return this.metrics.get(index).build();
  }
  
  public MetricSpec buildFirstMetric() {
    return this.metrics.get(0).build();
  }
  
  public MetricSpec buildLastMetric() {
    return this.metrics.get(metrics.size() - 1).build();
  }
  
  public MetricSpec buildMatchingMetric(Predicate predicate) {
      for (MetricSpecBuilder item : metrics) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingMetric(Predicate predicate) {
      for (MetricSpecBuilder item : metrics) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withMetrics(List metrics) {
    if (this.metrics != null) {
      this._visitables.get("metrics").clear();
    }
    if (metrics != null) {
        this.metrics = new ArrayList();
        for (MetricSpec item : metrics) {
          this.addToMetrics(item);
        }
    } else {
      this.metrics = null;
    }
    return (A) this;
  }
  
  public A withMetrics(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.MetricSpec... metrics) {
    if (this.metrics != null) {
        this.metrics.clear();
        _visitables.remove("metrics");
    }
    if (metrics != null) {
      for (MetricSpec item : metrics) {
        this.addToMetrics(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasMetrics() {
    return this.metrics != null && !this.metrics.isEmpty();
  }
  
  public MetricsNested addNewMetric() {
    return new MetricsNested(-1, null);
  }
  
  public MetricsNested addNewMetricLike(MetricSpec item) {
    return new MetricsNested(-1, item);
  }
  
  public MetricsNested setNewMetricLike(int index,MetricSpec item) {
    return new MetricsNested(index, item);
  }
  
  public MetricsNested editMetric(int index) {
    if (metrics.size() <= index) throw new RuntimeException("Can't edit metrics. Index exceeds size.");
    return setNewMetricLike(index, buildMetric(index));
  }
  
  public MetricsNested editFirstMetric() {
    if (metrics.size() == 0) throw new RuntimeException("Can't edit first metrics. The list is empty.");
    return setNewMetricLike(0, buildMetric(0));
  }
  
  public MetricsNested editLastMetric() {
    int index = metrics.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last metrics. The list is empty.");
    return setNewMetricLike(index, buildMetric(index));
  }
  
  public MetricsNested editMatchingMetric(Predicate predicate) {
    int index = -1;
    for (int i=0;i withNewScaleTargetRef() {
    return new ScaleTargetRefNested(null);
  }
  
  public ScaleTargetRefNested withNewScaleTargetRefLike(CrossVersionObjectReference item) {
    return new ScaleTargetRefNested(item);
  }
  
  public ScaleTargetRefNested editScaleTargetRef() {
    return withNewScaleTargetRefLike(java.util.Optional.ofNullable(buildScaleTargetRef()).orElse(null));
  }
  
  public ScaleTargetRefNested editOrNewScaleTargetRef() {
    return withNewScaleTargetRefLike(java.util.Optional.ofNullable(buildScaleTargetRef()).orElse(new CrossVersionObjectReferenceBuilder().build()));
  }
  
  public ScaleTargetRefNested editOrNewScaleTargetRefLike(CrossVersionObjectReference item) {
    return withNewScaleTargetRefLike(java.util.Optional.ofNullable(buildScaleTargetRef()).orElse(item));
  }
  
  public A addToAdditionalProperties(String key,Object value) {
    if(this.additionalProperties == null && key != null && value != null) { this.additionalProperties = new LinkedHashMap(); }
    if(key != null && value != null) {this.additionalProperties.put(key, value);} return (A)this;
  }
  
  public A addToAdditionalProperties(Map 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;
    HorizontalPodAutoscalerSpecFluent that = (HorizontalPodAutoscalerSpecFluent) o;
    if (!java.util.Objects.equals(behavior, that.behavior)) return false;
    if (!java.util.Objects.equals(maxReplicas, that.maxReplicas)) return false;
    if (!java.util.Objects.equals(metrics, that.metrics)) return false;
    if (!java.util.Objects.equals(minReplicas, that.minReplicas)) return false;
    if (!java.util.Objects.equals(scaleTargetRef, that.scaleTargetRef)) return false;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(behavior,  maxReplicas,  metrics,  minReplicas,  scaleTargetRef,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (behavior != null) { sb.append("behavior:"); sb.append(behavior + ","); }
    if (maxReplicas != null) { sb.append("maxReplicas:"); sb.append(maxReplicas + ","); }
    if (metrics != null && !metrics.isEmpty()) { sb.append("metrics:"); sb.append(metrics + ","); }
    if (minReplicas != null) { sb.append("minReplicas:"); sb.append(minReplicas + ","); }
    if (scaleTargetRef != null) { sb.append("scaleTargetRef:"); sb.append(scaleTargetRef + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class BehaviorNested extends HorizontalPodAutoscalerBehaviorFluent> implements Nested{
    BehaviorNested(HorizontalPodAutoscalerBehavior item) {
      this.builder = new HorizontalPodAutoscalerBehaviorBuilder(this, item);
    }
    HorizontalPodAutoscalerBehaviorBuilder builder;
    
    public N and() {
      return (N) HorizontalPodAutoscalerSpecFluent.this.withBehavior(builder.build());
    }
    
    public N endBehavior() {
      return and();
    }
    
  
  }
  public class MetricsNested extends MetricSpecFluent> implements Nested{
    MetricsNested(int index,MetricSpec item) {
      this.index = index;
      this.builder = new MetricSpecBuilder(this, item);
    }
    MetricSpecBuilder builder;
    int index;
    
    public N and() {
      return (N) HorizontalPodAutoscalerSpecFluent.this.setToMetrics(index,builder.build());
    }
    
    public N endMetric() {
      return and();
    }
    
  
  }
  public class ScaleTargetRefNested extends CrossVersionObjectReferenceFluent> implements Nested{
    ScaleTargetRefNested(CrossVersionObjectReference item) {
      this.builder = new CrossVersionObjectReferenceBuilder(this, item);
    }
    CrossVersionObjectReferenceBuilder builder;
    
    public N and() {
      return (N) HorizontalPodAutoscalerSpecFluent.this.withScaleTargetRef(builder.build());
    }
    
    public N endScaleTargetRef() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy