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

annotations.io.alauda.devops.api.model.DockerBuildStrategyFluentImpl 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 io.alauda.kubernetes.api.model.ObjectReference;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import io.alauda.kubernetes.api.model.LocalObjectReferenceFluentImpl;
import io.alauda.kubernetes.api.model.EnvVar;
import java.util.List;
import java.lang.Boolean;
import io.alauda.kubernetes.api.model.ObjectReferenceFluentImpl;
import io.alauda.kubernetes.api.model.LocalObjectReferenceBuilder;
import javax.validation.Valid;
import io.alauda.kubernetes.api.model.ObjectReferenceBuilder;
import io.alauda.kubernetes.api.model.LocalObjectReference;
import java.util.Collection;
import io.alauda.kubernetes.api.model.EnvVarFluentImpl;
import java.lang.Object;

public class DockerBuildStrategyFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements DockerBuildStrategyFluent{

    private List buildArgs =  new ArrayList();
    private String dockerfilePath;
    private List env =  new ArrayList();
    private Boolean forcePull;
    private ObjectReferenceBuilder from;
    private String imageOptimizationPolicy;
    private Boolean noCache;
    private LocalObjectReferenceBuilder pullSecret;

    public DockerBuildStrategyFluentImpl(){
    }
    public DockerBuildStrategyFluentImpl(DockerBuildStrategy instance){
            this.withBuildArgs(instance.getBuildArgs()); 
            this.withDockerfilePath(instance.getDockerfilePath()); 
            this.withEnv(instance.getEnv()); 
            this.withForcePull(instance.getForcePull()); 
            this.withFrom(instance.getFrom()); 
            this.withImageOptimizationPolicy(instance.getImageOptimizationPolicy()); 
            this.withNoCache(instance.getNoCache()); 
            this.withPullSecret(instance.getPullSecret()); 
    }

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

    public A setToBuildArgs(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 >= buildArgs.size()) { buildArgs.add(builder); } else { buildArgs.set(index, builder);}
             return (A)this;
    }

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

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

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

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

    
/**
 * This method has been deprecated, please use method buildBuildArgs instead.
 */
@Deprecated public List getBuildArgs(){
            return build(buildArgs);
    }

    public List buildBuildArgs(){
            return build(buildArgs);
    }

    public EnvVar buildBuildArg(int index){
            return this.buildArgs.get(index).build();
    }

    public EnvVar buildFirstBuildArg(){
            return this.buildArgs.get(0).build();
    }

    public EnvVar buildLastBuildArg(){
            return this.buildArgs.get(buildArgs.size() - 1).build();
    }

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

    public A withBuildArgs(List buildArgs){
            _visitables.removeAll(this.buildArgs);
            this.buildArgs.clear();
            if (buildArgs != null) {for (EnvVar item : buildArgs){this.addToBuildArgs(item);}} return (A) this;
    }

    public A withBuildArgs(EnvVar... buildArgs){
            this.buildArgs.clear(); if (buildArgs != null) {for (EnvVar item :buildArgs){ this.addToBuildArgs(item);}} return (A) this;
    }

    public Boolean hasBuildArgs(){
            return buildArgs!= null && !buildArgs.isEmpty();
    }

    public DockerBuildStrategyFluent.BuildArgsNested addNewBuildArg(){
            return new BuildArgsNestedImpl();
    }

    public DockerBuildStrategyFluent.BuildArgsNested addNewBuildArgLike(EnvVar item){
            return new BuildArgsNestedImpl(-1, item);
    }

    public DockerBuildStrategyFluent.BuildArgsNested setNewBuildArgLike(int index,EnvVar item){
            return new BuildArgsNestedImpl(index, item);
    }

    public DockerBuildStrategyFluent.BuildArgsNested editBuildArg(int index){
            if (buildArgs.size() <= index) throw new RuntimeException("Can't edit buildArgs. Index exceeds size.");
            return setNewBuildArgLike(index, buildBuildArg(index));
    }

    public DockerBuildStrategyFluent.BuildArgsNested editFirstBuildArg(){
            if (buildArgs.size() == 0) throw new RuntimeException("Can't edit first buildArgs. The list is empty.");
            return setNewBuildArgLike(0, buildBuildArg(0));
    }

    public DockerBuildStrategyFluent.BuildArgsNested editLastBuildArg(){
            int index = buildArgs.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last buildArgs. The list is empty.");
            return setNewBuildArgLike(index, buildBuildArg(index));
    }

    public DockerBuildStrategyFluent.BuildArgsNested editMatchingBuildArg(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i= 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 DockerBuildStrategyFluent.EnvNested addNewEnv(){
            return new EnvNestedImpl();
    }

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

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

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

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

    public DockerBuildStrategyFluent.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 DockerBuildStrategyFluent.EnvNested editMatchingEnv(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i withNewFrom(){
            return new FromNestedImpl();
    }

    public DockerBuildStrategyFluent.FromNested withNewFromLike(ObjectReference item){
            return new FromNestedImpl(item);
    }

    public DockerBuildStrategyFluent.FromNested editFrom(){
            return withNewFromLike(getFrom());
    }

    public DockerBuildStrategyFluent.FromNested editOrNewFrom(){
            return withNewFromLike(getFrom() != null ? getFrom(): new ObjectReferenceBuilder().build());
    }

    public DockerBuildStrategyFluent.FromNested editOrNewFromLike(ObjectReference item){
            return withNewFromLike(getFrom() != null ? getFrom(): item);
    }

    public String getImageOptimizationPolicy(){
            return this.imageOptimizationPolicy;
    }

    public A withImageOptimizationPolicy(String imageOptimizationPolicy){
            this.imageOptimizationPolicy=imageOptimizationPolicy; return (A) this;
    }

    public Boolean hasImageOptimizationPolicy(){
            return this.imageOptimizationPolicy!=null;
    }

    public Boolean isNoCache(){
            return this.noCache;
    }

    public A withNoCache(Boolean noCache){
            this.noCache=noCache; return (A) this;
    }

    public Boolean hasNoCache(){
            return this.noCache!=null;
    }

    
/**
 * This method has been deprecated, please use method buildPullSecret instead.
 */
@Deprecated public LocalObjectReference getPullSecret(){
            return this.pullSecret!=null?this.pullSecret.build():null;
    }

    public LocalObjectReference buildPullSecret(){
            return this.pullSecret!=null?this.pullSecret.build():null;
    }

    public A withPullSecret(LocalObjectReference pullSecret){
            _visitables.remove(this.pullSecret);
            if (pullSecret!=null){ this.pullSecret= new LocalObjectReferenceBuilder(pullSecret); _visitables.add(this.pullSecret);} return (A) this;
    }

    public Boolean hasPullSecret(){
            return this.pullSecret!=null;
    }

    public DockerBuildStrategyFluent.PullSecretNested withNewPullSecret(){
            return new PullSecretNestedImpl();
    }

    public DockerBuildStrategyFluent.PullSecretNested withNewPullSecretLike(LocalObjectReference item){
            return new PullSecretNestedImpl(item);
    }

    public DockerBuildStrategyFluent.PullSecretNested editPullSecret(){
            return withNewPullSecretLike(getPullSecret());
    }

    public DockerBuildStrategyFluent.PullSecretNested editOrNewPullSecret(){
            return withNewPullSecretLike(getPullSecret() != null ? getPullSecret(): new LocalObjectReferenceBuilder().build());
    }

    public DockerBuildStrategyFluent.PullSecretNested editOrNewPullSecretLike(LocalObjectReference item){
            return withNewPullSecretLike(getPullSecret() != null ? getPullSecret(): item);
    }

    public A withNewPullSecret(String name){
            return (A)withPullSecret(new LocalObjectReference(name));
    }

    public boolean equals(Object o){
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            if (!super.equals(o)) return false;
            DockerBuildStrategyFluentImpl that = (DockerBuildStrategyFluentImpl) o;
            if (buildArgs != null ? !buildArgs.equals(that.buildArgs) :that.buildArgs != null) return false;
            if (dockerfilePath != null ? !dockerfilePath.equals(that.dockerfilePath) :that.dockerfilePath != null) return false;
            if (env != null ? !env.equals(that.env) :that.env != null) return false;
            if (forcePull != null ? !forcePull.equals(that.forcePull) :that.forcePull != null) return false;
            if (from != null ? !from.equals(that.from) :that.from != null) return false;
            if (imageOptimizationPolicy != null ? !imageOptimizationPolicy.equals(that.imageOptimizationPolicy) :that.imageOptimizationPolicy != null) return false;
            if (noCache != null ? !noCache.equals(that.noCache) :that.noCache != null) return false;
            if (pullSecret != null ? !pullSecret.equals(that.pullSecret) :that.pullSecret != null) return false;
            return true;
    }


    public class BuildArgsNestedImpl extends EnvVarFluentImpl> implements DockerBuildStrategyFluent.BuildArgsNested,io.alauda.kubernetes.api.builder.Nested{

            private final EnvVarBuilder builder;
        private final int index;
    
            BuildArgsNestedImpl(int index,EnvVar item){
                    this.index = index;
                    this.builder = new EnvVarBuilder(this, item);
            }
            BuildArgsNestedImpl(){
                    this.index = -1;
                    this.builder = new EnvVarBuilder(this);
            }
    
    public N and(){
            return (N) DockerBuildStrategyFluentImpl.this.setToBuildArgs(index, builder.build());
    }
    public N endBuildArg(){
            return and();
    }

}
    public class EnvNestedImpl extends EnvVarFluentImpl> implements DockerBuildStrategyFluent.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) DockerBuildStrategyFluentImpl.this.setToEnv(index, builder.build());
    }
    public N endEnv(){
            return and();
    }

}
    public class FromNestedImpl extends ObjectReferenceFluentImpl> implements DockerBuildStrategyFluent.FromNested,io.alauda.kubernetes.api.builder.Nested{

            private final ObjectReferenceBuilder builder;
    
            FromNestedImpl(ObjectReference item){
                    this.builder = new ObjectReferenceBuilder(this, item);
            }
            FromNestedImpl(){
                    this.builder = new ObjectReferenceBuilder(this);
            }
    
    public N and(){
            return (N) DockerBuildStrategyFluentImpl.this.withFrom(builder.build());
    }
    public N endFrom(){
            return and();
    }

}
    public class PullSecretNestedImpl extends LocalObjectReferenceFluentImpl> implements DockerBuildStrategyFluent.PullSecretNested,io.alauda.kubernetes.api.builder.Nested{

            private final LocalObjectReferenceBuilder builder;
    
            PullSecretNestedImpl(LocalObjectReference item){
                    this.builder = new LocalObjectReferenceBuilder(this, item);
            }
            PullSecretNestedImpl(){
                    this.builder = new LocalObjectReferenceBuilder(this);
            }
    
    public N and(){
            return (N) DockerBuildStrategyFluentImpl.this.withPullSecret(builder.build());
    }
    public N endPullSecret(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy