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

io.fabric8.kubernetes.api.model.ExecConfigFluentImpl Maven / Gradle / Ivy

There is a newer version: 7.0.1
Show newest version
package io.fabric8.kubernetes.api.model;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.lang.StringBuilder;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.fabric8.kubernetes.api.builder.Predicate;
import java.lang.StringBuffer;
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;

public class ExecConfigFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements ExecConfigFluent{

    private String apiVersion;
    private List args = new ArrayList();
    private String command;
    private List env =  new ArrayList();

    public ExecConfigFluentImpl(){
    }
    public ExecConfigFluentImpl(ExecConfig instance){
            this.withApiVersion(instance.getApiVersion()); 
            this.withArgs(instance.getArgs()); 
            this.withCommand(instance.getCommand()); 
            this.withEnv(instance.getEnv()); 
    }

    public String getApiVersion(){
            return this.apiVersion;
    }

    public A withApiVersion(String apiVersion){
            this.apiVersion=apiVersion; return (A) this;
    }

    public Boolean hasApiVersion(){
            return this.apiVersion != null;
    }

    public A withNewApiVersion(String arg1){
            return (A)withApiVersion(new String(arg1));
    }

    public A withNewApiVersion(StringBuilder arg1){
            return (A)withApiVersion(new String(arg1));
    }

    public A withNewApiVersion(StringBuffer arg1){
            return (A)withApiVersion(new String(arg1));
    }

    public A addToArgs(int index,String item){
            if (this.args == null) {this.args = new ArrayList();}
            this.args.add(index, item);
            return (A)this;
    }

    public A setToArgs(int index,String item){
            if (this.args == null) {this.args = new ArrayList();}
            this.args.set(index, item); return (A)this;
    }

    public A addToArgs(String... items){
            if (this.args == null) {this.args = new ArrayList();}
            for (String item : items) {this.args.add(item);} return (A)this;
    }

    public A addAllToArgs(Collection items){
            if (this.args == null) {this.args = new ArrayList();}
            for (String item : items) {this.args.add(item);} return (A)this;
    }

    public A removeFromArgs(String... items){
            for (String item : items) {if (this.args!= null){ this.args.remove(item);}} return (A)this;
    }

    public A removeAllFromArgs(Collection items){
            for (String item : items) {if (this.args!= null){ this.args.remove(item);}} return (A)this;
    }

    public List getArgs(){
            return this.args;
    }

    public String getArg(int index){
            return this.args.get(index);
    }

    public String getFirstArg(){
            return this.args.get(0);
    }

    public String getLastArg(){
            return this.args.get(args.size() - 1);
    }

    public String getMatchingArg(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (String item: args) { if(predicate.apply(item)){ return item;} } return null;
    }

    public Boolean hasMatchingArg(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (String item: args) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withArgs(List args){
            if (this.args != null) { _visitables.get("args").removeAll(this.args);}
            if (args != null) {this.args = new ArrayList(); for (String item : args){this.addToArgs(item);}} else { this.args = null;} return (A) this;
    }

    public A withArgs(String... args){
            if (this.args != null) {this.args.clear();}
            if (args != null) {for (String item :args){ this.addToArgs(item);}} return (A) this;
    }

    public Boolean hasArgs(){
            return args != null && !args.isEmpty();
    }

    public A addNewArg(String arg1){
            return (A)addToArgs(new String(arg1));
    }

    public A addNewArg(StringBuilder arg1){
            return (A)addToArgs(new String(arg1));
    }

    public A addNewArg(StringBuffer arg1){
            return (A)addToArgs(new String(arg1));
    }

    public String getCommand(){
            return this.command;
    }

    public A withCommand(String command){
            this.command=command; return (A) this;
    }

    public Boolean hasCommand(){
            return this.command != null;
    }

    public A withNewCommand(String arg1){
            return (A)withCommand(new String(arg1));
    }

    public A withNewCommand(StringBuilder arg1){
            return (A)withCommand(new String(arg1));
    }

    public A withNewCommand(StringBuffer arg1){
            return (A)withCommand(new String(arg1));
    }

    public A addToEnv(int index,ExecEnvVar item){
            if (this.env == null) {this.env = new ArrayList();}
            ExecEnvVarBuilder builder = new ExecEnvVarBuilder(item);_visitables.get("env").add(index >= 0 ? index : _visitables.get("env").size(), builder);this.env.add(index >= 0 ? index : env.size(), builder); return (A)this;
    }

    public A setToEnv(int index,ExecEnvVar item){
            if (this.env == null) {this.env = new ArrayList();}
            ExecEnvVarBuilder builder = new ExecEnvVarBuilder(item);
            if (index < 0 || index >= _visitables.get("env").size()) { _visitables.get("env").add(builder); } else { _visitables.get("env").set(index, builder);}
            if (index < 0 || index >= env.size()) { env.add(builder); } else { env.set(index, builder);}
             return (A)this;
    }

    public A addToEnv(ExecEnvVar... items){
            if (this.env == null) {this.env = new ArrayList();}
            for (ExecEnvVar item : items) {ExecEnvVarBuilder builder = new ExecEnvVarBuilder(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 (ExecEnvVar item : items) {ExecEnvVarBuilder builder = new ExecEnvVarBuilder(item);_visitables.get("env").add(builder);this.env.add(builder);} return (A)this;
    }

    public A removeFromEnv(ExecEnvVar... items){
            for (ExecEnvVar item : items) {ExecEnvVarBuilder builder = new ExecEnvVarBuilder(item);_visitables.get("env").remove(builder);if (this.env != null) {this.env.remove(builder);}} return (A)this;
    }

    public A removeAllFromEnv(Collection items){
            for (ExecEnvVar item : items) {ExecEnvVarBuilder builder = new ExecEnvVarBuilder(item);_visitables.get("env").remove(builder);if (this.env != null) {this.env.remove(builder);}} return (A)this;
    }

    public A removeMatchingFromEnv(io.fabric8.kubernetes.api.builder.Predicate predicate){
            if (env == null) return (A) this;
            final Iterator each = env.iterator();
            final List visitables = _visitables.get("env");
            while (each.hasNext()) {
              ExecEnvVarBuilder builder = each.next();
              if (predicate.apply(builder)) {
                visitables.remove(builder);
                each.remove();
              }
            }
            return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildEnv instead.
 * @return The buildable object.
 */
@Deprecated public List getEnv(){
            return build(env);
    }

    public List buildEnv(){
            return build(env);
    }

    public ExecEnvVar buildEnv(int index){
            return this.env.get(index).build();
    }

    public ExecEnvVar buildFirstEnv(){
            return this.env.get(0).build();
    }

    public ExecEnvVar buildLastEnv(){
            return this.env.get(env.size() - 1).build();
    }

    public ExecEnvVar buildMatchingEnv(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (ExecEnvVarBuilder item: env) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingEnv(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (ExecEnvVarBuilder item: env) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withEnv(List env){
            if (this.env != null) { _visitables.get("env").removeAll(this.env);}
            if (env != null) {this.env = new ArrayList(); for (ExecEnvVar item : env){this.addToEnv(item);}} else { this.env = null;} return (A) this;
    }

    public A withEnv(ExecEnvVar... env){
            if (this.env != null) {this.env.clear();}
            if (env != null) {for (ExecEnvVar item :env){ this.addToEnv(item);}} return (A) this;
    }

    public Boolean hasEnv(){
            return env != null && !env.isEmpty();
    }

    public A addNewEnv(String name,String value){
            return (A)addToEnv(new ExecEnvVar(name, value));
    }

    public ExecConfigFluent.EnvNested addNewEnv(){
            return new EnvNestedImpl();
    }

    public ExecConfigFluent.EnvNested addNewEnvLike(ExecEnvVar item){
            return new EnvNestedImpl(-1, item);
    }

    public ExecConfigFluent.EnvNested setNewEnvLike(int index,ExecEnvVar item){
            return new EnvNestedImpl(index, item);
    }

    public ExecConfigFluent.EnvNested editEnv(int index){
            if (env.size() <= index) throw new RuntimeException("Can't edit env. Index exceeds size.");
            return setNewEnvLike(index, buildEnv(index));
    }

    public ExecConfigFluent.EnvNested editFirstEnv(){
            if (env.size() == 0) throw new RuntimeException("Can't edit first env. The list is empty.");
            return setNewEnvLike(0, buildEnv(0));
    }

    public ExecConfigFluent.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 ExecConfigFluent.EnvNested editMatchingEnv(io.fabric8.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends ExecEnvVarFluentImpl> implements ExecConfigFluent.EnvNested,io.fabric8.kubernetes.api.builder.Nested{

            private final ExecEnvVarBuilder builder;
        private final int index;
    
            EnvNestedImpl(int index,ExecEnvVar item){
                    this.index = index;
                    this.builder = new ExecEnvVarBuilder(this, item);
            }
            EnvNestedImpl(){
                    this.index = -1;
                    this.builder = new ExecEnvVarBuilder(this);
            }
    
    public N and(){
            return (N) ExecConfigFluentImpl.this.setToEnv(index,builder.build());
    }
    public N endEnv(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy