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

io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HorizontalPodAutoscalerStatusFluent 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.lang.Long;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class HorizontalPodAutoscalerStatusFluent> extends BaseFluent{
  public HorizontalPodAutoscalerStatusFluent() {
  }
  
  public HorizontalPodAutoscalerStatusFluent(HorizontalPodAutoscalerStatus instance) {
    this.copyInstance(instance);
  }
  private ArrayList conditions = new ArrayList();
  private ArrayList currentMetrics = new ArrayList();
  private Integer currentReplicas;
  private Integer desiredReplicas;
  private String lastScaleTime;
  private Long observedGeneration;
  private Map additionalProperties;
  
  protected void copyInstance(HorizontalPodAutoscalerStatus instance) {
    instance = (instance != null ? instance : new HorizontalPodAutoscalerStatus());
    if (instance != null) {
          this.withConditions(instance.getConditions());
          this.withCurrentMetrics(instance.getCurrentMetrics());
          this.withCurrentReplicas(instance.getCurrentReplicas());
          this.withDesiredReplicas(instance.getDesiredReplicas());
          this.withLastScaleTime(instance.getLastScaleTime());
          this.withObservedGeneration(instance.getObservedGeneration());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  public A addToConditions(int index,HorizontalPodAutoscalerCondition item) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    HorizontalPodAutoscalerConditionBuilder builder = new HorizontalPodAutoscalerConditionBuilder(item);
    if (index < 0 || index >= conditions.size()) { _visitables.get("conditions").add(builder); conditions.add(builder); } else { _visitables.get("conditions").add(index, builder); conditions.add(index, builder);}
    return (A)this;
  }
  
  public A setToConditions(int index,HorizontalPodAutoscalerCondition item) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    HorizontalPodAutoscalerConditionBuilder builder = new HorizontalPodAutoscalerConditionBuilder(item);
    if (index < 0 || index >= conditions.size()) { _visitables.get("conditions").add(builder); conditions.add(builder); } else { _visitables.get("conditions").set(index, builder); conditions.set(index, builder);}
    return (A)this;
  }
  
  public A addToConditions(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HorizontalPodAutoscalerCondition... items) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    for (HorizontalPodAutoscalerCondition item : items) {HorizontalPodAutoscalerConditionBuilder builder = new HorizontalPodAutoscalerConditionBuilder(item);_visitables.get("conditions").add(builder);this.conditions.add(builder);} return (A)this;
  }
  
  public A addAllToConditions(Collection items) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    for (HorizontalPodAutoscalerCondition item : items) {HorizontalPodAutoscalerConditionBuilder builder = new HorizontalPodAutoscalerConditionBuilder(item);_visitables.get("conditions").add(builder);this.conditions.add(builder);} return (A)this;
  }
  
  public A removeFromConditions(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HorizontalPodAutoscalerCondition... items) {
    if (this.conditions == null) return (A)this;
    for (HorizontalPodAutoscalerCondition item : items) {HorizontalPodAutoscalerConditionBuilder builder = new HorizontalPodAutoscalerConditionBuilder(item);_visitables.get("conditions").remove(builder); this.conditions.remove(builder);} return (A)this;
  }
  
  public A removeAllFromConditions(Collection items) {
    if (this.conditions == null) return (A)this;
    for (HorizontalPodAutoscalerCondition item : items) {HorizontalPodAutoscalerConditionBuilder builder = new HorizontalPodAutoscalerConditionBuilder(item);_visitables.get("conditions").remove(builder); this.conditions.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromConditions(Predicate predicate) {
    if (conditions == null) return (A) this;
    final Iterator each = conditions.iterator();
    final List visitables = _visitables.get("conditions");
    while (each.hasNext()) {
      HorizontalPodAutoscalerConditionBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildConditions() {
    return this.conditions != null ? build(conditions) : null;
  }
  
  public HorizontalPodAutoscalerCondition buildCondition(int index) {
    return this.conditions.get(index).build();
  }
  
  public HorizontalPodAutoscalerCondition buildFirstCondition() {
    return this.conditions.get(0).build();
  }
  
  public HorizontalPodAutoscalerCondition buildLastCondition() {
    return this.conditions.get(conditions.size() - 1).build();
  }
  
  public HorizontalPodAutoscalerCondition buildMatchingCondition(Predicate predicate) {
      for (HorizontalPodAutoscalerConditionBuilder item : conditions) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingCondition(Predicate predicate) {
      for (HorizontalPodAutoscalerConditionBuilder item : conditions) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withConditions(List conditions) {
    if (this.conditions != null) {
      this._visitables.get("conditions").clear();
    }
    if (conditions != null) {
        this.conditions = new ArrayList();
        for (HorizontalPodAutoscalerCondition item : conditions) {
          this.addToConditions(item);
        }
    } else {
      this.conditions = null;
    }
    return (A) this;
  }
  
  public A withConditions(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HorizontalPodAutoscalerCondition... conditions) {
    if (this.conditions != null) {
        this.conditions.clear();
        _visitables.remove("conditions");
    }
    if (conditions != null) {
      for (HorizontalPodAutoscalerCondition item : conditions) {
        this.addToConditions(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasConditions() {
    return this.conditions != null && !this.conditions.isEmpty();
  }
  
  public A addNewCondition(String lastTransitionTime,String message,String reason,String status,String type) {
    return (A)addToConditions(new HorizontalPodAutoscalerCondition(lastTransitionTime, message, reason, status, type));
  }
  
  public ConditionsNested addNewCondition() {
    return new ConditionsNested(-1, null);
  }
  
  public ConditionsNested addNewConditionLike(HorizontalPodAutoscalerCondition item) {
    return new ConditionsNested(-1, item);
  }
  
  public ConditionsNested setNewConditionLike(int index,HorizontalPodAutoscalerCondition item) {
    return new ConditionsNested(index, item);
  }
  
  public ConditionsNested editCondition(int index) {
    if (conditions.size() <= index) throw new RuntimeException("Can't edit conditions. Index exceeds size.");
    return setNewConditionLike(index, buildCondition(index));
  }
  
  public ConditionsNested editFirstCondition() {
    if (conditions.size() == 0) throw new RuntimeException("Can't edit first conditions. The list is empty.");
    return setNewConditionLike(0, buildCondition(0));
  }
  
  public ConditionsNested editLastCondition() {
    int index = conditions.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last conditions. The list is empty.");
    return setNewConditionLike(index, buildCondition(index));
  }
  
  public ConditionsNested editMatchingCondition(Predicate predicate) {
    int index = -1;
    for (int i=0;i();}
    MetricStatusBuilder builder = new MetricStatusBuilder(item);
    if (index < 0 || index >= currentMetrics.size()) { _visitables.get("currentMetrics").add(builder); currentMetrics.add(builder); } else { _visitables.get("currentMetrics").add(index, builder); currentMetrics.add(index, builder);}
    return (A)this;
  }
  
  public A setToCurrentMetrics(int index,MetricStatus item) {
    if (this.currentMetrics == null) {this.currentMetrics = new ArrayList();}
    MetricStatusBuilder builder = new MetricStatusBuilder(item);
    if (index < 0 || index >= currentMetrics.size()) { _visitables.get("currentMetrics").add(builder); currentMetrics.add(builder); } else { _visitables.get("currentMetrics").set(index, builder); currentMetrics.set(index, builder);}
    return (A)this;
  }
  
  public A addToCurrentMetrics(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.MetricStatus... items) {
    if (this.currentMetrics == null) {this.currentMetrics = new ArrayList();}
    for (MetricStatus item : items) {MetricStatusBuilder builder = new MetricStatusBuilder(item);_visitables.get("currentMetrics").add(builder);this.currentMetrics.add(builder);} return (A)this;
  }
  
  public A addAllToCurrentMetrics(Collection items) {
    if (this.currentMetrics == null) {this.currentMetrics = new ArrayList();}
    for (MetricStatus item : items) {MetricStatusBuilder builder = new MetricStatusBuilder(item);_visitables.get("currentMetrics").add(builder);this.currentMetrics.add(builder);} return (A)this;
  }
  
  public A removeFromCurrentMetrics(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.MetricStatus... items) {
    if (this.currentMetrics == null) return (A)this;
    for (MetricStatus item : items) {MetricStatusBuilder builder = new MetricStatusBuilder(item);_visitables.get("currentMetrics").remove(builder); this.currentMetrics.remove(builder);} return (A)this;
  }
  
  public A removeAllFromCurrentMetrics(Collection items) {
    if (this.currentMetrics == null) return (A)this;
    for (MetricStatus item : items) {MetricStatusBuilder builder = new MetricStatusBuilder(item);_visitables.get("currentMetrics").remove(builder); this.currentMetrics.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromCurrentMetrics(Predicate predicate) {
    if (currentMetrics == null) return (A) this;
    final Iterator each = currentMetrics.iterator();
    final List visitables = _visitables.get("currentMetrics");
    while (each.hasNext()) {
      MetricStatusBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildCurrentMetrics() {
    return this.currentMetrics != null ? build(currentMetrics) : null;
  }
  
  public MetricStatus buildCurrentMetric(int index) {
    return this.currentMetrics.get(index).build();
  }
  
  public MetricStatus buildFirstCurrentMetric() {
    return this.currentMetrics.get(0).build();
  }
  
  public MetricStatus buildLastCurrentMetric() {
    return this.currentMetrics.get(currentMetrics.size() - 1).build();
  }
  
  public MetricStatus buildMatchingCurrentMetric(Predicate predicate) {
      for (MetricStatusBuilder item : currentMetrics) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingCurrentMetric(Predicate predicate) {
      for (MetricStatusBuilder item : currentMetrics) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withCurrentMetrics(List currentMetrics) {
    if (this.currentMetrics != null) {
      this._visitables.get("currentMetrics").clear();
    }
    if (currentMetrics != null) {
        this.currentMetrics = new ArrayList();
        for (MetricStatus item : currentMetrics) {
          this.addToCurrentMetrics(item);
        }
    } else {
      this.currentMetrics = null;
    }
    return (A) this;
  }
  
  public A withCurrentMetrics(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.MetricStatus... currentMetrics) {
    if (this.currentMetrics != null) {
        this.currentMetrics.clear();
        _visitables.remove("currentMetrics");
    }
    if (currentMetrics != null) {
      for (MetricStatus item : currentMetrics) {
        this.addToCurrentMetrics(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasCurrentMetrics() {
    return this.currentMetrics != null && !this.currentMetrics.isEmpty();
  }
  
  public CurrentMetricsNested addNewCurrentMetric() {
    return new CurrentMetricsNested(-1, null);
  }
  
  public CurrentMetricsNested addNewCurrentMetricLike(MetricStatus item) {
    return new CurrentMetricsNested(-1, item);
  }
  
  public CurrentMetricsNested setNewCurrentMetricLike(int index,MetricStatus item) {
    return new CurrentMetricsNested(index, item);
  }
  
  public CurrentMetricsNested editCurrentMetric(int index) {
    if (currentMetrics.size() <= index) throw new RuntimeException("Can't edit currentMetrics. Index exceeds size.");
    return setNewCurrentMetricLike(index, buildCurrentMetric(index));
  }
  
  public CurrentMetricsNested editFirstCurrentMetric() {
    if (currentMetrics.size() == 0) throw new RuntimeException("Can't edit first currentMetrics. The list is empty.");
    return setNewCurrentMetricLike(0, buildCurrentMetric(0));
  }
  
  public CurrentMetricsNested editLastCurrentMetric() {
    int index = currentMetrics.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last currentMetrics. The list is empty.");
    return setNewCurrentMetricLike(index, buildCurrentMetric(index));
  }
  
  public CurrentMetricsNested editMatchingCurrentMetric(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;
    HorizontalPodAutoscalerStatusFluent that = (HorizontalPodAutoscalerStatusFluent) o;
    if (!java.util.Objects.equals(conditions, that.conditions)) return false;
    if (!java.util.Objects.equals(currentMetrics, that.currentMetrics)) return false;
    if (!java.util.Objects.equals(currentReplicas, that.currentReplicas)) return false;
    if (!java.util.Objects.equals(desiredReplicas, that.desiredReplicas)) return false;
    if (!java.util.Objects.equals(lastScaleTime, that.lastScaleTime)) return false;
    if (!java.util.Objects.equals(observedGeneration, that.observedGeneration)) return false;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(conditions,  currentMetrics,  currentReplicas,  desiredReplicas,  lastScaleTime,  observedGeneration,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (conditions != null && !conditions.isEmpty()) { sb.append("conditions:"); sb.append(conditions + ","); }
    if (currentMetrics != null && !currentMetrics.isEmpty()) { sb.append("currentMetrics:"); sb.append(currentMetrics + ","); }
    if (currentReplicas != null) { sb.append("currentReplicas:"); sb.append(currentReplicas + ","); }
    if (desiredReplicas != null) { sb.append("desiredReplicas:"); sb.append(desiredReplicas + ","); }
    if (lastScaleTime != null) { sb.append("lastScaleTime:"); sb.append(lastScaleTime + ","); }
    if (observedGeneration != null) { sb.append("observedGeneration:"); sb.append(observedGeneration + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class ConditionsNested extends HorizontalPodAutoscalerConditionFluent> implements Nested{
    ConditionsNested(int index,HorizontalPodAutoscalerCondition item) {
      this.index = index;
      this.builder = new HorizontalPodAutoscalerConditionBuilder(this, item);
    }
    HorizontalPodAutoscalerConditionBuilder builder;
    int index;
    
    public N and() {
      return (N) HorizontalPodAutoscalerStatusFluent.this.setToConditions(index,builder.build());
    }
    
    public N endCondition() {
      return and();
    }
    
  
  }
  public class CurrentMetricsNested extends MetricStatusFluent> implements Nested{
    CurrentMetricsNested(int index,MetricStatus item) {
      this.index = index;
      this.builder = new MetricStatusBuilder(this, item);
    }
    MetricStatusBuilder builder;
    int index;
    
    public N and() {
      return (N) HorizontalPodAutoscalerStatusFluent.this.setToCurrentMetrics(index,builder.build());
    }
    
    public N endCurrentMetric() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy