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

io.alauda.devops.api.model.JenkinsPipelineBuildStrategyFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.2.12
Show newest version
package io.alauda.devops.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.alauda.kubernetes.api.model.EnvVarBuilder;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import io.alauda.kubernetes.api.model.EnvVar;
import java.util.Collection;
import io.alauda.kubernetes.api.model.EnvVarFluentImpl;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class JenkinsPipelineBuildStrategyFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements JenkinsPipelineBuildStrategyFluent{

    private List env =  new ArrayList();
    private String jenkinsfile;
    private String jenkinsfilePath;

    public JenkinsPipelineBuildStrategyFluentImpl(){
    }
    public JenkinsPipelineBuildStrategyFluentImpl(JenkinsPipelineBuildStrategy instance){
            this.withEnv(instance.getEnv()); 
            this.withJenkinsfile(instance.getJenkinsfile()); 
            this.withJenkinsfilePath(instance.getJenkinsfilePath()); 
    }

    public A addToEnv(int index,EnvVar item){
            EnvVarBuilder builder = new EnvVarBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.env.add(index >= 0 ? index : env.size(), builder); return (A)this;
    }

    public A setToEnv(int index,EnvVar item){
            EnvVarBuilder builder = new EnvVarBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= env.size()) { env.add(builder); } else { env.set(index, builder);}
             return (A)this;
    }

    public A addToEnv(EnvVar... items){
            for (EnvVar item : items) {EnvVarBuilder builder = new EnvVarBuilder(item);_visitables.add(builder);this.env.add(builder);} return (A)this;
    }

    public A addAllToEnv(Collection items){
            for (EnvVar item : items) {EnvVarBuilder builder = new EnvVarBuilder(item);_visitables.add(builder);this.env.add(builder);} return (A)this;
    }

    public A removeFromEnv(EnvVar... items){
            for (EnvVar item : items) {EnvVarBuilder builder = new EnvVarBuilder(item);_visitables.remove(builder);this.env.remove(builder);} return (A)this;
    }

    public A removeAllFromEnv(Collection items){
            for (EnvVar item : items) {EnvVarBuilder builder = new EnvVarBuilder(item);_visitables.remove(builder);this.env.remove(builder);} return (A)this;
    }

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

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

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

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

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

    public EnvVar buildMatchingEnv(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (EnvVarBuilder item: env) { if(predicate.apply(item)){return item.build();} } return null;
    }

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

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

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

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

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

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

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

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

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

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

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy