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

io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.PrioritizerPolicyFluent Maven / Gradle / Ivy

package io.fabric8.openclustermanagement.api.model.cluster.v1alpha1;

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

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class PrioritizerPolicyFluent> extends BaseFluent{
  public PrioritizerPolicyFluent() {
  }
  
  public PrioritizerPolicyFluent(PrioritizerPolicy instance) {
    this.copyInstance(instance);
  }
  private ArrayList configurations = new ArrayList();
  private String mode;
  private Map additionalProperties;
  
  protected void copyInstance(PrioritizerPolicy instance) {
    instance = (instance != null ? instance : new PrioritizerPolicy());
    if (instance != null) {
          this.withConfigurations(instance.getConfigurations());
          this.withMode(instance.getMode());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  public A addToConfigurations(int index,PrioritizerConfig item) {
    if (this.configurations == null) {this.configurations = new ArrayList();}
    PrioritizerConfigBuilder builder = new PrioritizerConfigBuilder(item);
    if (index < 0 || index >= configurations.size()) { _visitables.get("configurations").add(builder); configurations.add(builder); } else { _visitables.get("configurations").add(index, builder); configurations.add(index, builder);}
    return (A)this;
  }
  
  public A setToConfigurations(int index,PrioritizerConfig item) {
    if (this.configurations == null) {this.configurations = new ArrayList();}
    PrioritizerConfigBuilder builder = new PrioritizerConfigBuilder(item);
    if (index < 0 || index >= configurations.size()) { _visitables.get("configurations").add(builder); configurations.add(builder); } else { _visitables.get("configurations").set(index, builder); configurations.set(index, builder);}
    return (A)this;
  }
  
  public A addToConfigurations(io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.PrioritizerConfig... items) {
    if (this.configurations == null) {this.configurations = new ArrayList();}
    for (PrioritizerConfig item : items) {PrioritizerConfigBuilder builder = new PrioritizerConfigBuilder(item);_visitables.get("configurations").add(builder);this.configurations.add(builder);} return (A)this;
  }
  
  public A addAllToConfigurations(Collection items) {
    if (this.configurations == null) {this.configurations = new ArrayList();}
    for (PrioritizerConfig item : items) {PrioritizerConfigBuilder builder = new PrioritizerConfigBuilder(item);_visitables.get("configurations").add(builder);this.configurations.add(builder);} return (A)this;
  }
  
  public A removeFromConfigurations(io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.PrioritizerConfig... items) {
    if (this.configurations == null) return (A)this;
    for (PrioritizerConfig item : items) {PrioritizerConfigBuilder builder = new PrioritizerConfigBuilder(item);_visitables.get("configurations").remove(builder); this.configurations.remove(builder);} return (A)this;
  }
  
  public A removeAllFromConfigurations(Collection items) {
    if (this.configurations == null) return (A)this;
    for (PrioritizerConfig item : items) {PrioritizerConfigBuilder builder = new PrioritizerConfigBuilder(item);_visitables.get("configurations").remove(builder); this.configurations.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromConfigurations(Predicate predicate) {
    if (configurations == null) return (A) this;
    final Iterator each = configurations.iterator();
    final List visitables = _visitables.get("configurations");
    while (each.hasNext()) {
      PrioritizerConfigBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildConfigurations() {
    return this.configurations != null ? build(configurations) : null;
  }
  
  public PrioritizerConfig buildConfiguration(int index) {
    return this.configurations.get(index).build();
  }
  
  public PrioritizerConfig buildFirstConfiguration() {
    return this.configurations.get(0).build();
  }
  
  public PrioritizerConfig buildLastConfiguration() {
    return this.configurations.get(configurations.size() - 1).build();
  }
  
  public PrioritizerConfig buildMatchingConfiguration(Predicate predicate) {
      for (PrioritizerConfigBuilder item : configurations) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingConfiguration(Predicate predicate) {
      for (PrioritizerConfigBuilder item : configurations) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withConfigurations(List configurations) {
    if (this.configurations != null) {
      this._visitables.get("configurations").clear();
    }
    if (configurations != null) {
        this.configurations = new ArrayList();
        for (PrioritizerConfig item : configurations) {
          this.addToConfigurations(item);
        }
    } else {
      this.configurations = null;
    }
    return (A) this;
  }
  
  public A withConfigurations(io.fabric8.openclustermanagement.api.model.cluster.v1alpha1.PrioritizerConfig... configurations) {
    if (this.configurations != null) {
        this.configurations.clear();
        _visitables.remove("configurations");
    }
    if (configurations != null) {
      for (PrioritizerConfig item : configurations) {
        this.addToConfigurations(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasConfigurations() {
    return this.configurations != null && !this.configurations.isEmpty();
  }
  
  public A addNewConfiguration(String name,Integer weight) {
    return (A)addToConfigurations(new PrioritizerConfig(name, weight));
  }
  
  public ConfigurationsNested addNewConfiguration() {
    return new ConfigurationsNested(-1, null);
  }
  
  public ConfigurationsNested addNewConfigurationLike(PrioritizerConfig item) {
    return new ConfigurationsNested(-1, item);
  }
  
  public ConfigurationsNested setNewConfigurationLike(int index,PrioritizerConfig item) {
    return new ConfigurationsNested(index, item);
  }
  
  public ConfigurationsNested editConfiguration(int index) {
    if (configurations.size() <= index) throw new RuntimeException("Can't edit configurations. Index exceeds size.");
    return setNewConfigurationLike(index, buildConfiguration(index));
  }
  
  public ConfigurationsNested editFirstConfiguration() {
    if (configurations.size() == 0) throw new RuntimeException("Can't edit first configurations. The list is empty.");
    return setNewConfigurationLike(0, buildConfiguration(0));
  }
  
  public ConfigurationsNested editLastConfiguration() {
    int index = configurations.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last configurations. The list is empty.");
    return setNewConfigurationLike(index, buildConfiguration(index));
  }
  
  public ConfigurationsNested editMatchingConfiguration(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;
    PrioritizerPolicyFluent that = (PrioritizerPolicyFluent) o;
    if (!java.util.Objects.equals(configurations, that.configurations)) return false;
    if (!java.util.Objects.equals(mode, that.mode)) return false;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(configurations,  mode,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (configurations != null && !configurations.isEmpty()) { sb.append("configurations:"); sb.append(configurations + ","); }
    if (mode != null) { sb.append("mode:"); sb.append(mode + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class ConfigurationsNested extends PrioritizerConfigFluent> implements Nested{
    ConfigurationsNested(int index,PrioritizerConfig item) {
      this.index = index;
      this.builder = new PrioritizerConfigBuilder(this, item);
    }
    PrioritizerConfigBuilder builder;
    int index;
    
    public N and() {
      return (N) PrioritizerPolicyFluent.this.setToConfigurations(index,builder.build());
    }
    
    public N endConfiguration() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy