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

io.kubernetes.client.openapi.models.V2HorizontalPodAutoscalerStatusFluent 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.lang.Integer;
import java.time.OffsetDateTime;
import java.lang.Long;
import java.util.Collection;
import java.lang.Object;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class V2HorizontalPodAutoscalerStatusFluent> extends BaseFluent{
  public V2HorizontalPodAutoscalerStatusFluent() {
  }
  
  public V2HorizontalPodAutoscalerStatusFluent(V2HorizontalPodAutoscalerStatus instance) {
    this.copyInstance(instance);
  }
  private ArrayList conditions;
  private ArrayList currentMetrics;
  private Integer currentReplicas;
  private Integer desiredReplicas;
  private OffsetDateTime lastScaleTime;
  private Long observedGeneration;
  
  protected void copyInstance(V2HorizontalPodAutoscalerStatus instance) {
    instance = (instance != null ? instance : new V2HorizontalPodAutoscalerStatus());
    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());
        }
  }
  
  public A addToConditions(int index,V2HorizontalPodAutoscalerCondition item) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    V2HorizontalPodAutoscalerConditionBuilder builder = new V2HorizontalPodAutoscalerConditionBuilder(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,V2HorizontalPodAutoscalerCondition item) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    V2HorizontalPodAutoscalerConditionBuilder builder = new V2HorizontalPodAutoscalerConditionBuilder(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.kubernetes.client.openapi.models.V2HorizontalPodAutoscalerCondition... items) {
    if (this.conditions == null) {this.conditions = new ArrayList();}
    for (V2HorizontalPodAutoscalerCondition item : items) {V2HorizontalPodAutoscalerConditionBuilder builder = new V2HorizontalPodAutoscalerConditionBuilder(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 (V2HorizontalPodAutoscalerCondition item : items) {V2HorizontalPodAutoscalerConditionBuilder builder = new V2HorizontalPodAutoscalerConditionBuilder(item);_visitables.get("conditions").add(builder);this.conditions.add(builder);} return (A)this;
  }
  
  public A removeFromConditions(io.kubernetes.client.openapi.models.V2HorizontalPodAutoscalerCondition... items) {
    if (this.conditions == null) return (A)this;
    for (V2HorizontalPodAutoscalerCondition item : items) {V2HorizontalPodAutoscalerConditionBuilder builder = new V2HorizontalPodAutoscalerConditionBuilder(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 (V2HorizontalPodAutoscalerCondition item : items) {V2HorizontalPodAutoscalerConditionBuilder builder = new V2HorizontalPodAutoscalerConditionBuilder(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()) {
      V2HorizontalPodAutoscalerConditionBuilder 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 V2HorizontalPodAutoscalerCondition buildCondition(int index) {
    return this.conditions.get(index).build();
  }
  
  public V2HorizontalPodAutoscalerCondition buildFirstCondition() {
    return this.conditions.get(0).build();
  }
  
  public V2HorizontalPodAutoscalerCondition buildLastCondition() {
    return this.conditions.get(conditions.size() - 1).build();
  }
  
  public V2HorizontalPodAutoscalerCondition buildMatchingCondition(Predicate predicate) {
      for (V2HorizontalPodAutoscalerConditionBuilder item : conditions) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingCondition(Predicate predicate) {
      for (V2HorizontalPodAutoscalerConditionBuilder 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 (V2HorizontalPodAutoscalerCondition item : conditions) {
          this.addToConditions(item);
        }
    } else {
      this.conditions = null;
    }
    return (A) this;
  }
  
  public A withConditions(io.kubernetes.client.openapi.models.V2HorizontalPodAutoscalerCondition... conditions) {
    if (this.conditions != null) {
        this.conditions.clear();
        _visitables.remove("conditions");
    }
    if (conditions != null) {
      for (V2HorizontalPodAutoscalerCondition item : conditions) {
        this.addToConditions(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasConditions() {
    return this.conditions != null && !this.conditions.isEmpty();
  }
  
  public ConditionsNested addNewCondition() {
    return new ConditionsNested(-1, null);
  }
  
  public ConditionsNested addNewConditionLike(V2HorizontalPodAutoscalerCondition item) {
    return new ConditionsNested(-1, item);
  }
  
  public ConditionsNested setNewConditionLike(int index,V2HorizontalPodAutoscalerCondition 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();}
    V2MetricStatusBuilder builder = new V2MetricStatusBuilder(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,V2MetricStatus item) {
    if (this.currentMetrics == null) {this.currentMetrics = new ArrayList();}
    V2MetricStatusBuilder builder = new V2MetricStatusBuilder(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.kubernetes.client.openapi.models.V2MetricStatus... items) {
    if (this.currentMetrics == null) {this.currentMetrics = new ArrayList();}
    for (V2MetricStatus item : items) {V2MetricStatusBuilder builder = new V2MetricStatusBuilder(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 (V2MetricStatus item : items) {V2MetricStatusBuilder builder = new V2MetricStatusBuilder(item);_visitables.get("currentMetrics").add(builder);this.currentMetrics.add(builder);} return (A)this;
  }
  
  public A removeFromCurrentMetrics(io.kubernetes.client.openapi.models.V2MetricStatus... items) {
    if (this.currentMetrics == null) return (A)this;
    for (V2MetricStatus item : items) {V2MetricStatusBuilder builder = new V2MetricStatusBuilder(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 (V2MetricStatus item : items) {V2MetricStatusBuilder builder = new V2MetricStatusBuilder(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()) {
      V2MetricStatusBuilder 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 V2MetricStatus buildCurrentMetric(int index) {
    return this.currentMetrics.get(index).build();
  }
  
  public V2MetricStatus buildFirstCurrentMetric() {
    return this.currentMetrics.get(0).build();
  }
  
  public V2MetricStatus buildLastCurrentMetric() {
    return this.currentMetrics.get(currentMetrics.size() - 1).build();
  }
  
  public V2MetricStatus buildMatchingCurrentMetric(Predicate predicate) {
      for (V2MetricStatusBuilder item : currentMetrics) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingCurrentMetric(Predicate predicate) {
      for (V2MetricStatusBuilder 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 (V2MetricStatus item : currentMetrics) {
          this.addToCurrentMetrics(item);
        }
    } else {
      this.currentMetrics = null;
    }
    return (A) this;
  }
  
  public A withCurrentMetrics(io.kubernetes.client.openapi.models.V2MetricStatus... currentMetrics) {
    if (this.currentMetrics != null) {
        this.currentMetrics.clear();
        _visitables.remove("currentMetrics");
    }
    if (currentMetrics != null) {
      for (V2MetricStatus 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(V2MetricStatus item) {
    return new CurrentMetricsNested(-1, item);
  }
  
  public CurrentMetricsNested setNewCurrentMetricLike(int index,V2MetricStatus 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 extends V2HorizontalPodAutoscalerConditionFluent> implements Nested{
    ConditionsNested(int index,V2HorizontalPodAutoscalerCondition item) {
      this.index = index;
      this.builder = new V2HorizontalPodAutoscalerConditionBuilder(this, item);
    }
    V2HorizontalPodAutoscalerConditionBuilder builder;
    int index;
    
    public N and() {
      return (N) V2HorizontalPodAutoscalerStatusFluent.this.setToConditions(index,builder.build());
    }
    
    public N endCondition() {
      return and();
    }
    
  
  }
  public class CurrentMetricsNested extends V2MetricStatusFluent> implements Nested{
    CurrentMetricsNested(int index,V2MetricStatus item) {
      this.index = index;
      this.builder = new V2MetricStatusBuilder(this, item);
    }
    V2MetricStatusBuilder builder;
    int index;
    
    public N and() {
      return (N) V2HorizontalPodAutoscalerStatusFluent.this.setToCurrentMetrics(index,builder.build());
    }
    
    public N endCurrentMetric() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy