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

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

package io.fabric8.kubernetes.api.model.autoscaling.v2beta2;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
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 java.lang.Integer;
import java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
import java.util.Map;

 /**
  * Generated
  */
public class HPAScalingRulesFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent{
  public HPAScalingRulesFluentImpl() {
  }
  public HPAScalingRulesFluentImpl(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRules instance) {
    this.withPolicies(instance.getPolicies()); 
    this.withSelectPolicy(instance.getSelectPolicy()); 
    this.withStabilizationWindowSeconds(instance.getStabilizationWindowSeconds()); 
    this.withAdditionalProperties(instance.getAdditionalProperties());

  }
  private java.util.List policies =  new java.util.ArrayList();
  private java.lang.String selectPolicy;
  private java.lang.Integer stabilizationWindowSeconds;
  private java.util.Map additionalProperties;
  public A addToPolicies(java.lang.Integer index,io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item) {
    if (this.policies == null) {this.policies = new java.util.ArrayList();}
    io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(item);_visitables.get("policies").add(index >= 0 ? index : _visitables.get("policies").size(), builder);this.policies.add(index >= 0 ? index : policies.size(), builder); return (A)this;
  }
  public A setToPolicies(java.lang.Integer index,io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item) {
    if (this.policies == null) {this.policies = new java.util.ArrayList();}
    io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(item);
    if (index < 0 || index >= _visitables.get("policies").size()) { _visitables.get("policies").add(builder); } else { _visitables.get("policies").set(index, builder);}
    if (index < 0 || index >= policies.size()) { policies.add(builder); } else { policies.set(index, builder);}
     return (A)this;
  }
  public A addToPolicies(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy... items) {
    if (this.policies == null) {this.policies = new java.util.ArrayList();}
    for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item : items) {io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(item);_visitables.get("policies").add(builder);this.policies.add(builder);} return (A)this;
  }
  public A addAllToPolicies(java.util.Collection items) {
    if (this.policies == null) {this.policies = new java.util.ArrayList();}
    for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item : items) {io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(item);_visitables.get("policies").add(builder);this.policies.add(builder);} return (A)this;
  }
  public A removeFromPolicies(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy... items) {
    for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item : items) {io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(item);_visitables.get("policies").remove(builder);if (this.policies != null) {this.policies.remove(builder);}} return (A)this;
  }
  public A removeAllFromPolicies(java.util.Collection items) {
    for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item : items) {io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(item);_visitables.get("policies").remove(builder);if (this.policies != null) {this.policies.remove(builder);}} return (A)this;
  }
  public A removeMatchingFromPolicies(java.util.function.Predicate predicate) {
    if (policies == null) return (A) this;
    final Iterator each = policies.iterator();
    final List visitables = _visitables.get("policies");
    while (each.hasNext()) {
      io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  /**
   * This method has been deprecated, please use method buildPolicies instead.
   * @return The buildable object.
   */
  @java.lang.Deprecated
  public java.util.List getPolicies() {
    return build(policies);
  }
  public java.util.List buildPolicies() {
    return build(policies);
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy buildPolicy(java.lang.Integer index) {
    return this.policies.get(index).build();
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy buildFirstPolicy() {
    return this.policies.get(0).build();
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy buildLastPolicy() {
    return this.policies.get(policies.size() - 1).build();
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy buildMatchingPolicy(java.util.function.Predicate predicate) {
    for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder item: policies) { if(predicate.test(item)){ return item.build();} } return null;
  }
  public java.lang.Boolean hasMatchingPolicy(java.util.function.Predicate predicate) {
    for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder item: policies) { if(predicate.test(item)){ return true;} } return false;
  }
  public A withPolicies(java.util.List policies) {
    if (this.policies != null) { _visitables.get("policies").removeAll(this.policies);}
    if (policies != null) {this.policies = new java.util.ArrayList(); for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item : policies){this.addToPolicies(item);}} else { this.policies = null;} return (A) this;
  }
  public A withPolicies(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy... policies) {
    if (this.policies != null) {this.policies.clear();}
    if (policies != null) {for (io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item :policies){ this.addToPolicies(item);}} return (A) this;
  }
  public java.lang.Boolean hasPolicies() {
    return policies != null && !policies.isEmpty();
  }
  public A addNewPolicy(java.lang.Integer periodSeconds,java.lang.String type,java.lang.Integer value) {
    return (A)addToPolicies(new HPAScalingPolicy(periodSeconds, type, value));
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested addNewPolicy() {
    return new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluentImpl.PoliciesNestedImpl();
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested addNewPolicyLike(io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item) {
    return new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluentImpl.PoliciesNestedImpl(-1, item);
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested setNewPolicyLike(java.lang.Integer index,io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item) {
    return new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluentImpl.PoliciesNestedImpl(index, item);
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested editPolicy(java.lang.Integer index) {
    if (policies.size() <= index) throw new RuntimeException("Can't edit policies. Index exceeds size.");
    return setNewPolicyLike(index, buildPolicy(index));
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested editFirstPolicy() {
    if (policies.size() == 0) throw new RuntimeException("Can't edit first policies. The list is empty.");
    return setNewPolicyLike(0, buildPolicy(0));
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested editLastPolicy() {
    int index = policies.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last policies. The list is empty.");
    return setNewPolicyLike(index, buildPolicy(index));
  }
  public io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested editMatchingPolicy(java.util.function.Predicate predicate) {
    int index = -1;
    for (int i=0;i map) {
    if(this.additionalProperties == null && map != null) { this.additionalProperties = new java.util.LinkedHashMap(); }
    if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
  }
  public A removeFromAdditionalProperties(java.lang.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(java.util.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 java.util.Map getAdditionalProperties() {
    return this.additionalProperties;
  }
  public A withAdditionalProperties(java.util.Map additionalProperties) {
    if (additionalProperties == null) { this.additionalProperties =  null;} else {this.additionalProperties = new java.util.LinkedHashMap(additionalProperties);} return (A) this;
  }
  public java.lang.Boolean hasAdditionalProperties() {
    return this.additionalProperties != null;
  }
  public boolean equals(java.lang.Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    HPAScalingRulesFluentImpl that = (HPAScalingRulesFluentImpl) o;
    if (policies != null ? !policies.equals(that.policies) :that.policies != null) return false;
    if (selectPolicy != null ? !selectPolicy.equals(that.selectPolicy) :that.selectPolicy != null) return false;
    if (stabilizationWindowSeconds != null ? !stabilizationWindowSeconds.equals(that.stabilizationWindowSeconds) :that.stabilizationWindowSeconds != null) return false;
    if (additionalProperties != null ? !additionalProperties.equals(that.additionalProperties) :that.additionalProperties != null) return false;
    return true;
  }
  public int hashCode() {
    return java.util.Objects.hash(policies,  selectPolicy,  stabilizationWindowSeconds,  additionalProperties,  super.hashCode());
  }
  public class PoliciesNestedImpl extends io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyFluentImpl> implements io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingRulesFluent.PoliciesNested,io.fabric8.kubernetes.api.builder.Nested{
    PoliciesNestedImpl(java.lang.Integer index,io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicy item) {
      this.index = index;
      this.builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(this, item);
    }
    PoliciesNestedImpl() {
      this.index = -1;
      this.builder = new io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder(this);
    }
    io.fabric8.kubernetes.api.model.autoscaling.v2beta2.HPAScalingPolicyBuilder builder;
    java.lang.Integer index;
    public N and() {
      return (N) HPAScalingRulesFluentImpl.this.setToPolicies(index,builder.build());
    }
    public N endPolicy() {
      return and();
    }
    
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy