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

io.strimzi.api.kafka.model.common.template.ContainerTemplateFluent Maven / Gradle / Ivy

The newest version!
package io.strimzi.api.kafka.model.common.template;

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

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class ContainerTemplateFluent> extends BaseFluent{
  public ContainerTemplateFluent() {
  }
  
  public ContainerTemplateFluent(ContainerTemplate instance) {
    this.copyInstance(instance);
  }
  private ArrayList env;
  private SecurityContext securityContext;
  private List volumeMounts;
  
  protected void copyInstance(ContainerTemplate instance) {
    instance = (instance != null ? instance : new ContainerTemplate());
    if (instance != null) {
          this.withEnv(instance.getEnv());
          this.withSecurityContext(instance.getSecurityContext());
          this.withVolumeMounts(instance.getVolumeMounts());
        }
  }
  
  public A addToEnv(int index,ContainerEnvVar item) {
    if (this.env == null) {this.env = new ArrayList();}
    ContainerEnvVarBuilder builder = new ContainerEnvVarBuilder(item);
    if (index < 0 || index >= env.size()) { _visitables.get("env").add(builder); env.add(builder); } else { _visitables.get("env").add(index, builder); env.add(index, builder);}
    return (A)this;
  }
  
  public A setToEnv(int index,ContainerEnvVar item) {
    if (this.env == null) {this.env = new ArrayList();}
    ContainerEnvVarBuilder builder = new ContainerEnvVarBuilder(item);
    if (index < 0 || index >= env.size()) { _visitables.get("env").add(builder); env.add(builder); } else { _visitables.get("env").set(index, builder); env.set(index, builder);}
    return (A)this;
  }
  
  public A addToEnv(io.strimzi.api.kafka.model.common.template.ContainerEnvVar... items) {
    if (this.env == null) {this.env = new ArrayList();}
    for (ContainerEnvVar item : items) {ContainerEnvVarBuilder builder = new ContainerEnvVarBuilder(item);_visitables.get("env").add(builder);this.env.add(builder);} return (A)this;
  }
  
  public A addAllToEnv(Collection items) {
    if (this.env == null) {this.env = new ArrayList();}
    for (ContainerEnvVar item : items) {ContainerEnvVarBuilder builder = new ContainerEnvVarBuilder(item);_visitables.get("env").add(builder);this.env.add(builder);} return (A)this;
  }
  
  public A removeFromEnv(io.strimzi.api.kafka.model.common.template.ContainerEnvVar... items) {
    if (this.env == null) return (A)this;
    for (ContainerEnvVar item : items) {ContainerEnvVarBuilder builder = new ContainerEnvVarBuilder(item);_visitables.get("env").remove(builder); this.env.remove(builder);} return (A)this;
  }
  
  public A removeAllFromEnv(Collection items) {
    if (this.env == null) return (A)this;
    for (ContainerEnvVar item : items) {ContainerEnvVarBuilder builder = new ContainerEnvVarBuilder(item);_visitables.get("env").remove(builder); this.env.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromEnv(Predicate predicate) {
    if (env == null) return (A) this;
    final Iterator each = env.iterator();
    final List visitables = _visitables.get("env");
    while (each.hasNext()) {
      ContainerEnvVarBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildEnv() {
    return this.env != null ? build(env) : null;
  }
  
  public ContainerEnvVar buildEnv(int index) {
    return this.env.get(index).build();
  }
  
  public ContainerEnvVar buildFirstEnv() {
    return this.env.get(0).build();
  }
  
  public ContainerEnvVar buildLastEnv() {
    return this.env.get(env.size() - 1).build();
  }
  
  public ContainerEnvVar buildMatchingEnv(Predicate predicate) {
      for (ContainerEnvVarBuilder item : env) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingEnv(Predicate predicate) {
      for (ContainerEnvVarBuilder item : env) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withEnv(List env) {
    if (this.env != null) {
      this._visitables.get("env").clear();
    }
    if (env != null) {
        this.env = new ArrayList();
        for (ContainerEnvVar item : env) {
          this.addToEnv(item);
        }
    } else {
      this.env = null;
    }
    return (A) this;
  }
  
  public A withEnv(io.strimzi.api.kafka.model.common.template.ContainerEnvVar... env) {
    if (this.env != null) {
        this.env.clear();
        _visitables.remove("env");
    }
    if (env != null) {
      for (ContainerEnvVar item : env) {
        this.addToEnv(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasEnv() {
    return this.env != null && !this.env.isEmpty();
  }
  
  public EnvNested addNewEnv() {
    return new EnvNested(-1, null);
  }
  
  public EnvNested addNewEnvLike(ContainerEnvVar item) {
    return new EnvNested(-1, item);
  }
  
  public EnvNested setNewEnvLike(int index,ContainerEnvVar item) {
    return new EnvNested(index, item);
  }
  
  public EnvNested editEnv(int index) {
    if (env.size() <= index) throw new RuntimeException("Can't edit env. Index exceeds size.");
    return setNewEnvLike(index, buildEnv(index));
  }
  
  public EnvNested editFirstEnv() {
    if (env.size() == 0) throw new RuntimeException("Can't edit first env. The list is empty.");
    return setNewEnvLike(0, buildEnv(0));
  }
  
  public EnvNested editLastEnv() {
    int index = env.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last env. The list is empty.");
    return setNewEnvLike(index, buildEnv(index));
  }
  
  public EnvNested editMatchingEnv(Predicate predicate) {
    int index = -1;
    for (int i=0;i();}
    this.volumeMounts.add(index, item);
    return (A)this;
  }
  
  public A setToVolumeMounts(int index,VolumeMount item) {
    if (this.volumeMounts == null) {this.volumeMounts = new ArrayList();}
    this.volumeMounts.set(index, item); return (A)this;
  }
  
  public A addToVolumeMounts(io.fabric8.kubernetes.api.model.VolumeMount... items) {
    if (this.volumeMounts == null) {this.volumeMounts = new ArrayList();}
    for (VolumeMount item : items) {this.volumeMounts.add(item);} return (A)this;
  }
  
  public A addAllToVolumeMounts(Collection items) {
    if (this.volumeMounts == null) {this.volumeMounts = new ArrayList();}
    for (VolumeMount item : items) {this.volumeMounts.add(item);} return (A)this;
  }
  
  public A removeFromVolumeMounts(io.fabric8.kubernetes.api.model.VolumeMount... items) {
    if (this.volumeMounts == null) return (A)this;
    for (VolumeMount item : items) { this.volumeMounts.remove(item);} return (A)this;
  }
  
  public A removeAllFromVolumeMounts(Collection items) {
    if (this.volumeMounts == null) return (A)this;
    for (VolumeMount item : items) { this.volumeMounts.remove(item);} return (A)this;
  }
  
  public List getVolumeMounts() {
    return this.volumeMounts;
  }
  
  public VolumeMount getVolumeMount(int index) {
    return this.volumeMounts.get(index);
  }
  
  public VolumeMount getFirstVolumeMount() {
    return this.volumeMounts.get(0);
  }
  
  public VolumeMount getLastVolumeMount() {
    return this.volumeMounts.get(volumeMounts.size() - 1);
  }
  
  public VolumeMount getMatchingVolumeMount(Predicate predicate) {
      for (VolumeMount item : volumeMounts) {
        if (predicate.test(item)) {
          return item;
        }
      }
      return null;
  }
  
  public boolean hasMatchingVolumeMount(Predicate predicate) {
      for (VolumeMount item : volumeMounts) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withVolumeMounts(List volumeMounts) {
    if (volumeMounts != null) {
        this.volumeMounts = new ArrayList();
        for (VolumeMount item : volumeMounts) {
          this.addToVolumeMounts(item);
        }
    } else {
      this.volumeMounts = null;
    }
    return (A) this;
  }
  
  public A withVolumeMounts(io.fabric8.kubernetes.api.model.VolumeMount... volumeMounts) {
    if (this.volumeMounts != null) {
        this.volumeMounts.clear();
        _visitables.remove("volumeMounts");
    }
    if (volumeMounts != null) {
      for (VolumeMount item : volumeMounts) {
        this.addToVolumeMounts(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasVolumeMounts() {
    return this.volumeMounts != null && !this.volumeMounts.isEmpty();
  }
  
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    ContainerTemplateFluent that = (ContainerTemplateFluent) o;
    if (!java.util.Objects.equals(env, that.env)) return false;
    if (!java.util.Objects.equals(securityContext, that.securityContext)) return false;
    if (!java.util.Objects.equals(volumeMounts, that.volumeMounts)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(env,  securityContext,  volumeMounts,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (env != null && !env.isEmpty()) { sb.append("env:"); sb.append(env + ","); }
    if (securityContext != null) { sb.append("securityContext:"); sb.append(securityContext + ","); }
    if (volumeMounts != null && !volumeMounts.isEmpty()) { sb.append("volumeMounts:"); sb.append(volumeMounts); }
    sb.append("}");
    return sb.toString();
  }
  public class EnvNested extends ContainerEnvVarFluent> implements Nested{
    EnvNested(int index,ContainerEnvVar item) {
      this.index = index;
      this.builder = new ContainerEnvVarBuilder(this, item);
    }
    ContainerEnvVarBuilder builder;
    int index;
    
    public N and() {
      return (N) ContainerTemplateFluent.this.setToEnv(index,builder.build());
    }
    
    public N endEnv() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy