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

io.fabric8.openshift.api.model.tuned.v1.TunedRecommendFluent Maven / Gradle / Ivy

The newest version!
package io.fabric8.openshift.api.model.tuned.v1;

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.Long;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class TunedRecommendFluent> extends BaseFluent{
  public TunedRecommendFluent() {
  }
  
  public TunedRecommendFluent(TunedRecommend instance) {
    this.copyInstance(instance);
  }
  private Map machineConfigLabels;
  private ArrayList match = new ArrayList();
  private OperandConfigBuilder operand;
  private Long priority;
  private String profile;
  private Map additionalProperties;
  
  protected void copyInstance(TunedRecommend instance) {
    instance = (instance != null ? instance : new TunedRecommend());
    if (instance != null) {
          this.withMachineConfigLabels(instance.getMachineConfigLabels());
          this.withMatch(instance.getMatch());
          this.withOperand(instance.getOperand());
          this.withPriority(instance.getPriority());
          this.withProfile(instance.getProfile());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  public A addToMachineConfigLabels(String key,String value) {
    if(this.machineConfigLabels == null && key != null && value != null) { this.machineConfigLabels = new LinkedHashMap(); }
    if(key != null && value != null) {this.machineConfigLabels.put(key, value);} return (A)this;
  }
  
  public A addToMachineConfigLabels(Map map) {
    if(this.machineConfigLabels == null && map != null) { this.machineConfigLabels = new LinkedHashMap(); }
    if(map != null) { this.machineConfigLabels.putAll(map);} return (A)this;
  }
  
  public A removeFromMachineConfigLabels(String key) {
    if(this.machineConfigLabels == null) { return (A) this; }
    if(key != null && this.machineConfigLabels != null) {this.machineConfigLabels.remove(key);} return (A)this;
  }
  
  public A removeFromMachineConfigLabels(Map map) {
    if(this.machineConfigLabels == null) { return (A) this; }
    if(map != null) { for(Object key : map.keySet()) {if (this.machineConfigLabels != null){this.machineConfigLabels.remove(key);}}} return (A)this;
  }
  
  public Map getMachineConfigLabels() {
    return this.machineConfigLabels;
  }
  
  public A withMachineConfigLabels(Map machineConfigLabels) {
    if (machineConfigLabels == null) {
      this.machineConfigLabels = null;
    } else {
      this.machineConfigLabels = new LinkedHashMap(machineConfigLabels);
    }
    return (A) this;
  }
  
  public boolean hasMachineConfigLabels() {
    return this.machineConfigLabels != null;
  }
  
  public A addToMatch(int index,TunedMatch item) {
    if (this.match == null) {this.match = new ArrayList();}
    TunedMatchBuilder builder = new TunedMatchBuilder(item);
    if (index < 0 || index >= match.size()) { _visitables.get("match").add(builder); match.add(builder); } else { _visitables.get("match").add(index, builder); match.add(index, builder);}
    return (A)this;
  }
  
  public A setToMatch(int index,TunedMatch item) {
    if (this.match == null) {this.match = new ArrayList();}
    TunedMatchBuilder builder = new TunedMatchBuilder(item);
    if (index < 0 || index >= match.size()) { _visitables.get("match").add(builder); match.add(builder); } else { _visitables.get("match").set(index, builder); match.set(index, builder);}
    return (A)this;
  }
  
  public A addToMatch(io.fabric8.openshift.api.model.tuned.v1.TunedMatch... items) {
    if (this.match == null) {this.match = new ArrayList();}
    for (TunedMatch item : items) {TunedMatchBuilder builder = new TunedMatchBuilder(item);_visitables.get("match").add(builder);this.match.add(builder);} return (A)this;
  }
  
  public A addAllToMatch(Collection items) {
    if (this.match == null) {this.match = new ArrayList();}
    for (TunedMatch item : items) {TunedMatchBuilder builder = new TunedMatchBuilder(item);_visitables.get("match").add(builder);this.match.add(builder);} return (A)this;
  }
  
  public A removeFromMatch(io.fabric8.openshift.api.model.tuned.v1.TunedMatch... items) {
    if (this.match == null) return (A)this;
    for (TunedMatch item : items) {TunedMatchBuilder builder = new TunedMatchBuilder(item);_visitables.get("match").remove(builder); this.match.remove(builder);} return (A)this;
  }
  
  public A removeAllFromMatch(Collection items) {
    if (this.match == null) return (A)this;
    for (TunedMatch item : items) {TunedMatchBuilder builder = new TunedMatchBuilder(item);_visitables.get("match").remove(builder); this.match.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromMatch(Predicate predicate) {
    if (match == null) return (A) this;
    final Iterator each = match.iterator();
    final List visitables = _visitables.get("match");
    while (each.hasNext()) {
      TunedMatchBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildMatch() {
    return this.match != null ? build(match) : null;
  }
  
  public TunedMatch buildMatch(int index) {
    return this.match.get(index).build();
  }
  
  public TunedMatch buildFirstMatch() {
    return this.match.get(0).build();
  }
  
  public TunedMatch buildLastMatch() {
    return this.match.get(match.size() - 1).build();
  }
  
  public TunedMatch buildMatchingMatch(Predicate predicate) {
      for (TunedMatchBuilder item : match) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingMatch(Predicate predicate) {
      for (TunedMatchBuilder item : match) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withMatch(List match) {
    if (this.match != null) {
      this._visitables.get("match").clear();
    }
    if (match != null) {
        this.match = new ArrayList();
        for (TunedMatch item : match) {
          this.addToMatch(item);
        }
    } else {
      this.match = null;
    }
    return (A) this;
  }
  
  public A withMatch(io.fabric8.openshift.api.model.tuned.v1.TunedMatch... match) {
    if (this.match != null) {
        this.match.clear();
        _visitables.remove("match");
    }
    if (match != null) {
      for (TunedMatch item : match) {
        this.addToMatch(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasMatch() {
    return this.match != null && !this.match.isEmpty();
  }
  
  public MatchNested addNewMatch() {
    return new MatchNested(-1, null);
  }
  
  public MatchNested addNewMatchLike(TunedMatch item) {
    return new MatchNested(-1, item);
  }
  
  public MatchNested setNewMatchLike(int index,TunedMatch item) {
    return new MatchNested(index, item);
  }
  
  public MatchNested editMatch(int index) {
    if (match.size() <= index) throw new RuntimeException("Can't edit match. Index exceeds size.");
    return setNewMatchLike(index, buildMatch(index));
  }
  
  public MatchNested editFirstMatch() {
    if (match.size() == 0) throw new RuntimeException("Can't edit first match. The list is empty.");
    return setNewMatchLike(0, buildMatch(0));
  }
  
  public MatchNested editLastMatch() {
    int index = match.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last match. The list is empty.");
    return setNewMatchLike(index, buildMatch(index));
  }
  
  public MatchNested editMatchingMatch(Predicate predicate) {
    int index = -1;
    for (int i=0;i withNewOperand() {
    return new OperandNested(null);
  }
  
  public OperandNested withNewOperandLike(OperandConfig item) {
    return new OperandNested(item);
  }
  
  public OperandNested editOperand() {
    return withNewOperandLike(java.util.Optional.ofNullable(buildOperand()).orElse(null));
  }
  
  public OperandNested editOrNewOperand() {
    return withNewOperandLike(java.util.Optional.ofNullable(buildOperand()).orElse(new OperandConfigBuilder().build()));
  }
  
  public OperandNested editOrNewOperandLike(OperandConfig item) {
    return withNewOperandLike(java.util.Optional.ofNullable(buildOperand()).orElse(item));
  }
  
  public Long getPriority() {
    return this.priority;
  }
  
  public A withPriority(Long priority) {
    this.priority = priority;
    return (A) this;
  }
  
  public boolean hasPriority() {
    return this.priority != null;
  }
  
  public String getProfile() {
    return this.profile;
  }
  
  public A withProfile(String profile) {
    this.profile = profile;
    return (A) this;
  }
  
  public boolean hasProfile() {
    return this.profile != null;
  }
  
  public A addToAdditionalProperties(String key,Object value) {
    if(this.additionalProperties == null && key != null && value != null) { this.additionalProperties = new LinkedHashMap(); }
    if(key != null && value != null) {this.additionalProperties.put(key, value);} return (A)this;
  }
  
  public A addToAdditionalProperties(Map 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;
    TunedRecommendFluent that = (TunedRecommendFluent) o;
    if (!java.util.Objects.equals(machineConfigLabels, that.machineConfigLabels)) return false;
    if (!java.util.Objects.equals(match, that.match)) return false;
    if (!java.util.Objects.equals(operand, that.operand)) return false;
    if (!java.util.Objects.equals(priority, that.priority)) return false;
    if (!java.util.Objects.equals(profile, that.profile)) return false;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(machineConfigLabels,  match,  operand,  priority,  profile,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (machineConfigLabels != null && !machineConfigLabels.isEmpty()) { sb.append("machineConfigLabels:"); sb.append(machineConfigLabels + ","); }
    if (match != null && !match.isEmpty()) { sb.append("match:"); sb.append(match + ","); }
    if (operand != null) { sb.append("operand:"); sb.append(operand + ","); }
    if (priority != null) { sb.append("priority:"); sb.append(priority + ","); }
    if (profile != null) { sb.append("profile:"); sb.append(profile + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class MatchNested extends TunedMatchFluent> implements Nested{
    MatchNested(int index,TunedMatch item) {
      this.index = index;
      this.builder = new TunedMatchBuilder(this, item);
    }
    TunedMatchBuilder builder;
    int index;
    
    public N and() {
      return (N) TunedRecommendFluent.this.setToMatch(index,builder.build());
    }
    
    public N endMatch() {
      return and();
    }
    
  
  }
  public class OperandNested extends OperandConfigFluent> implements Nested{
    OperandNested(OperandConfig item) {
      this.builder = new OperandConfigBuilder(this, item);
    }
    OperandConfigBuilder builder;
    
    public N and() {
      return (N) TunedRecommendFluent.this.withOperand(builder.build());
    }
    
    public N endOperand() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy