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 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 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
  */
  @SuppressWarnings(value = "unchecked")
  public class HPAScalingRulesFluentImpl> extends BaseFluent implements HPAScalingRulesFluent{
  public HPAScalingRulesFluentImpl() {
  }
  public HPAScalingRulesFluentImpl(HPAScalingRules instance) {
    this.withPolicies(instance.getPolicies()); 
    this.withSelectPolicy(instance.getSelectPolicy()); 
    this.withStabilizationWindowSeconds(instance.getStabilizationWindowSeconds()); 
    this.withAdditionalProperties(instance.getAdditionalProperties());

  }
  private ArrayList policies = new ArrayList();
  private String selectPolicy;
  private Integer stabilizationWindowSeconds;
  private Map additionalProperties;
  public A addToPolicies(Integer index,HPAScalingPolicy item) {
    if (this.policies == null) {this.policies = new ArrayList();}
    HPAScalingPolicyBuilder builder = new 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(Integer index,HPAScalingPolicy item) {
    if (this.policies == null) {this.policies = new ArrayList();}
    HPAScalingPolicyBuilder builder = new 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 ArrayList();}
    for (HPAScalingPolicy item : items) {HPAScalingPolicyBuilder builder = new HPAScalingPolicyBuilder(item);_visitables.get("policies").add(builder);this.policies.add(builder);} return (A)this;
  }
  public A addAllToPolicies(Collection items) {
    if (this.policies == null) {this.policies = new ArrayList();}
    for (HPAScalingPolicy item : items) {HPAScalingPolicyBuilder builder = new 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 (HPAScalingPolicy item : items) {HPAScalingPolicyBuilder builder = new HPAScalingPolicyBuilder(item);_visitables.get("policies").remove(builder);if (this.policies != null) {this.policies.remove(builder);}} return (A)this;
  }
  public A removeAllFromPolicies(Collection items) {
    for (HPAScalingPolicy item : items) {HPAScalingPolicyBuilder builder = new HPAScalingPolicyBuilder(item);_visitables.get("policies").remove(builder);if (this.policies != null) {this.policies.remove(builder);}} return (A)this;
  }
  public A removeMatchingFromPolicies(Predicate predicate) {
    if (policies == null) return (A) this;
    final Iterator each = policies.iterator();
    final List visitables = _visitables.get("policies");
    while (each.hasNext()) {
      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.
   */
  @Deprecated
  public List getPolicies() {
    return policies != null ? build(policies) : null;
  }
  public List buildPolicies() {
    return policies != null ? build(policies) : null;
  }
  public HPAScalingPolicy buildPolicy(Integer index) {
    return this.policies.get(index).build();
  }
  public HPAScalingPolicy buildFirstPolicy() {
    return this.policies.get(0).build();
  }
  public HPAScalingPolicy buildLastPolicy() {
    return this.policies.get(policies.size() - 1).build();
  }
  public HPAScalingPolicy buildMatchingPolicy(Predicate predicate) {
    for (HPAScalingPolicyBuilder item: policies) { if(predicate.test(item)){ return item.build();} } return null;
  }
  public Boolean hasMatchingPolicy(Predicate predicate) {
    for (HPAScalingPolicyBuilder item: policies) { if(predicate.test(item)){ return true;} } return false;
  }
  public A withPolicies(List policies) {
    if (this.policies != null) { _visitables.get("policies").removeAll(this.policies);}
    if (policies != null) {this.policies = new ArrayList(); for (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 (HPAScalingPolicy item :policies){ this.addToPolicies(item);}} return (A) this;
  }
  public Boolean hasPolicies() {
    return policies != null && !policies.isEmpty();
  }
  public A addNewPolicy(Integer periodSeconds,String type,Integer value) {
    return (A)addToPolicies(new HPAScalingPolicy(periodSeconds, type, value));
  }
  public HPAScalingRulesFluent.PoliciesNested addNewPolicy() {
    return new HPAScalingRulesFluentImpl.PoliciesNestedImpl();
  }
  public HPAScalingRulesFluent.PoliciesNested addNewPolicyLike(HPAScalingPolicy item) {
    return new HPAScalingRulesFluentImpl.PoliciesNestedImpl(-1, item);
  }
  public HPAScalingRulesFluent.PoliciesNested setNewPolicyLike(Integer index,HPAScalingPolicy item) {
    return new HPAScalingRulesFluentImpl.PoliciesNestedImpl(index, item);
  }
  public HPAScalingRulesFluent.PoliciesNested editPolicy(Integer index) {
    if (policies.size() <= index) throw new RuntimeException("Can't edit policies. Index exceeds size.");
    return setNewPolicyLike(index, buildPolicy(index));
  }
  public 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 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 HPAScalingRulesFluent.PoliciesNested editMatchingPolicy(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;
    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 String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (policies != null && !policies.isEmpty()) { sb.append("policies:"); sb.append(policies + ","); }
    if (selectPolicy != null) { sb.append("selectPolicy:"); sb.append(selectPolicy + ","); }
    if (stabilizationWindowSeconds != null) { sb.append("stabilizationWindowSeconds:"); sb.append(stabilizationWindowSeconds + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  class PoliciesNestedImpl extends HPAScalingPolicyFluentImpl> implements HPAScalingRulesFluent.PoliciesNested,Nested{
    PoliciesNestedImpl(Integer index,HPAScalingPolicy item) {
      this.index = index;
      this.builder = new HPAScalingPolicyBuilder(this, item);
    }
    PoliciesNestedImpl() {
      this.index = -1;
      this.builder = new HPAScalingPolicyBuilder(this);
    }
    HPAScalingPolicyBuilder builder;
    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