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

annotations.io.alauda.kubernetes.api.model.PipelineConfigSpecFluentImpl Maven / Gradle / Ivy

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

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

public class PipelineConfigSpecFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PipelineConfigSpecFluent{

    private List hooks =  new ArrayList();
    private LocalObjectReferenceBuilder jenkinsBinding;
    private List parameters =  new ArrayList();
    private PipelineRunLimitsBuilder runLimits;
    private String runPolicy;
    private PipelineSourceBuilder source;
    private PipelineStrategyBuilder strategy;
    private List triggers =  new ArrayList();

    public PipelineConfigSpecFluentImpl(){
    }
    public PipelineConfigSpecFluentImpl(PipelineConfigSpec instance){
            this.withHooks(instance.getHooks()); 
            this.withJenkinsBinding(instance.getJenkinsBinding()); 
            this.withParameters(instance.getParameters()); 
            this.withRunLimits(instance.getRunLimits()); 
            this.withRunPolicy(instance.getRunPolicy()); 
            this.withSource(instance.getSource()); 
            this.withStrategy(instance.getStrategy()); 
            this.withTriggers(instance.getTriggers()); 
    }

    public A addToHooks(int index,PipelineHook item){
            PipelineHookBuilder builder = new PipelineHookBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.hooks.add(index >= 0 ? index : hooks.size(), builder); return (A)this;
    }

    public A setToHooks(int index,PipelineHook item){
            PipelineHookBuilder builder = new PipelineHookBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= hooks.size()) { hooks.add(builder); } else { hooks.set(index, builder);}
             return (A)this;
    }

    public A addToHooks(PipelineHook... items){
            for (PipelineHook item : items) {PipelineHookBuilder builder = new PipelineHookBuilder(item);_visitables.add(builder);this.hooks.add(builder);} return (A)this;
    }

    public A addAllToHooks(Collection items){
            for (PipelineHook item : items) {PipelineHookBuilder builder = new PipelineHookBuilder(item);_visitables.add(builder);this.hooks.add(builder);} return (A)this;
    }

    public A removeFromHooks(PipelineHook... items){
            for (PipelineHook item : items) {PipelineHookBuilder builder = new PipelineHookBuilder(item);_visitables.remove(builder);this.hooks.remove(builder);} return (A)this;
    }

    public A removeAllFromHooks(Collection items){
            for (PipelineHook item : items) {PipelineHookBuilder builder = new PipelineHookBuilder(item);_visitables.remove(builder);this.hooks.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildHooks instead.
 */
@Deprecated public List getHooks(){
            return build(hooks);
    }

    public List buildHooks(){
            return build(hooks);
    }

    public PipelineHook buildHook(int index){
            return this.hooks.get(index).build();
    }

    public PipelineHook buildFirstHook(){
            return this.hooks.get(0).build();
    }

    public PipelineHook buildLastHook(){
            return this.hooks.get(hooks.size() - 1).build();
    }

    public PipelineHook buildMatchingHook(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (PipelineHookBuilder item: hooks) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withHooks(List hooks){
            _visitables.removeAll(this.hooks);
            this.hooks.clear();
            if (hooks != null) {for (PipelineHook item : hooks){this.addToHooks(item);}} return (A) this;
    }

    public A withHooks(PipelineHook... hooks){
            this.hooks.clear(); if (hooks != null) {for (PipelineHook item :hooks){ this.addToHooks(item);}} return (A) this;
    }

    public Boolean hasHooks(){
            return hooks!= null && !hooks.isEmpty();
    }

    public PipelineConfigSpecFluent.HooksNested addNewHook(){
            return new HooksNestedImpl();
    }

    public PipelineConfigSpecFluent.HooksNested addNewHookLike(PipelineHook item){
            return new HooksNestedImpl(-1, item);
    }

    public PipelineConfigSpecFluent.HooksNested setNewHookLike(int index,PipelineHook item){
            return new HooksNestedImpl(index, item);
    }

    public PipelineConfigSpecFluent.HooksNested editHook(int index){
            if (hooks.size() <= index) throw new RuntimeException("Can't edit hooks. Index exceeds size.");
            return setNewHookLike(index, buildHook(index));
    }

    public PipelineConfigSpecFluent.HooksNested editFirstHook(){
            if (hooks.size() == 0) throw new RuntimeException("Can't edit first hooks. The list is empty.");
            return setNewHookLike(0, buildHook(0));
    }

    public PipelineConfigSpecFluent.HooksNested editLastHook(){
            int index = hooks.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last hooks. The list is empty.");
            return setNewHookLike(index, buildHook(index));
    }

    public PipelineConfigSpecFluent.HooksNested editMatchingHook(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i withNewJenkinsBinding(){
            return new JenkinsBindingNestedImpl();
    }

    public PipelineConfigSpecFluent.JenkinsBindingNested withNewJenkinsBindingLike(LocalObjectReference item){
            return new JenkinsBindingNestedImpl(item);
    }

    public PipelineConfigSpecFluent.JenkinsBindingNested editJenkinsBinding(){
            return withNewJenkinsBindingLike(getJenkinsBinding());
    }

    public PipelineConfigSpecFluent.JenkinsBindingNested editOrNewJenkinsBinding(){
            return withNewJenkinsBindingLike(getJenkinsBinding() != null ? getJenkinsBinding(): new LocalObjectReferenceBuilder().build());
    }

    public PipelineConfigSpecFluent.JenkinsBindingNested editOrNewJenkinsBindingLike(LocalObjectReference item){
            return withNewJenkinsBindingLike(getJenkinsBinding() != null ? getJenkinsBinding(): item);
    }

    public A withNewJenkinsBinding(String name){
            return (A)withJenkinsBinding(new LocalObjectReference(name));
    }

    public A addToParameters(int index,PipelineParameter item){
            PipelineParameterBuilder builder = new PipelineParameterBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.parameters.add(index >= 0 ? index : parameters.size(), builder); return (A)this;
    }

    public A setToParameters(int index,PipelineParameter item){
            PipelineParameterBuilder builder = new PipelineParameterBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= parameters.size()) { parameters.add(builder); } else { parameters.set(index, builder);}
             return (A)this;
    }

    public A addToParameters(PipelineParameter... items){
            for (PipelineParameter item : items) {PipelineParameterBuilder builder = new PipelineParameterBuilder(item);_visitables.add(builder);this.parameters.add(builder);} return (A)this;
    }

    public A addAllToParameters(Collection items){
            for (PipelineParameter item : items) {PipelineParameterBuilder builder = new PipelineParameterBuilder(item);_visitables.add(builder);this.parameters.add(builder);} return (A)this;
    }

    public A removeFromParameters(PipelineParameter... items){
            for (PipelineParameter item : items) {PipelineParameterBuilder builder = new PipelineParameterBuilder(item);_visitables.remove(builder);this.parameters.remove(builder);} return (A)this;
    }

    public A removeAllFromParameters(Collection items){
            for (PipelineParameter item : items) {PipelineParameterBuilder builder = new PipelineParameterBuilder(item);_visitables.remove(builder);this.parameters.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildParameters instead.
 */
@Deprecated public List getParameters(){
            return build(parameters);
    }

    public List buildParameters(){
            return build(parameters);
    }

    public PipelineParameter buildParameter(int index){
            return this.parameters.get(index).build();
    }

    public PipelineParameter buildFirstParameter(){
            return this.parameters.get(0).build();
    }

    public PipelineParameter buildLastParameter(){
            return this.parameters.get(parameters.size() - 1).build();
    }

    public PipelineParameter buildMatchingParameter(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (PipelineParameterBuilder item: parameters) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withParameters(List parameters){
            _visitables.removeAll(this.parameters);
            this.parameters.clear();
            if (parameters != null) {for (PipelineParameter item : parameters){this.addToParameters(item);}} return (A) this;
    }

    public A withParameters(PipelineParameter... parameters){
            this.parameters.clear(); if (parameters != null) {for (PipelineParameter item :parameters){ this.addToParameters(item);}} return (A) this;
    }

    public Boolean hasParameters(){
            return parameters!= null && !parameters.isEmpty();
    }

    public PipelineConfigSpecFluent.ParametersNested addNewParameter(){
            return new ParametersNestedImpl();
    }

    public PipelineConfigSpecFluent.ParametersNested addNewParameterLike(PipelineParameter item){
            return new ParametersNestedImpl(-1, item);
    }

    public PipelineConfigSpecFluent.ParametersNested setNewParameterLike(int index,PipelineParameter item){
            return new ParametersNestedImpl(index, item);
    }

    public PipelineConfigSpecFluent.ParametersNested editParameter(int index){
            if (parameters.size() <= index) throw new RuntimeException("Can't edit parameters. Index exceeds size.");
            return setNewParameterLike(index, buildParameter(index));
    }

    public PipelineConfigSpecFluent.ParametersNested editFirstParameter(){
            if (parameters.size() == 0) throw new RuntimeException("Can't edit first parameters. The list is empty.");
            return setNewParameterLike(0, buildParameter(0));
    }

    public PipelineConfigSpecFluent.ParametersNested editLastParameter(){
            int index = parameters.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last parameters. The list is empty.");
            return setNewParameterLike(index, buildParameter(index));
    }

    public PipelineConfigSpecFluent.ParametersNested editMatchingParameter(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i withNewRunLimits(){
            return new RunLimitsNestedImpl();
    }

    public PipelineConfigSpecFluent.RunLimitsNested withNewRunLimitsLike(PipelineRunLimits item){
            return new RunLimitsNestedImpl(item);
    }

    public PipelineConfigSpecFluent.RunLimitsNested editRunLimits(){
            return withNewRunLimitsLike(getRunLimits());
    }

    public PipelineConfigSpecFluent.RunLimitsNested editOrNewRunLimits(){
            return withNewRunLimitsLike(getRunLimits() != null ? getRunLimits(): new PipelineRunLimitsBuilder().build());
    }

    public PipelineConfigSpecFluent.RunLimitsNested editOrNewRunLimitsLike(PipelineRunLimits item){
            return withNewRunLimitsLike(getRunLimits() != null ? getRunLimits(): item);
    }

    public A withNewRunLimits(Long failureCount,Long successCount){
            return (A)withRunLimits(new PipelineRunLimits(failureCount, successCount));
    }

    public String getRunPolicy(){
            return this.runPolicy;
    }

    public A withRunPolicy(String runPolicy){
            this.runPolicy=runPolicy; return (A) this;
    }

    public Boolean hasRunPolicy(){
            return this.runPolicy!=null;
    }

    
/**
 * This method has been deprecated, please use method buildSource instead.
 */
@Deprecated public PipelineSource getSource(){
            return this.source!=null?this.source.build():null;
    }

    public PipelineSource buildSource(){
            return this.source!=null?this.source.build():null;
    }

    public A withSource(PipelineSource source){
            _visitables.remove(this.source);
            if (source!=null){ this.source= new PipelineSourceBuilder(source); _visitables.add(this.source);} return (A) this;
    }

    public Boolean hasSource(){
            return this.source!=null;
    }

    public PipelineConfigSpecFluent.SourceNested withNewSource(){
            return new SourceNestedImpl();
    }

    public PipelineConfigSpecFluent.SourceNested withNewSourceLike(PipelineSource item){
            return new SourceNestedImpl(item);
    }

    public PipelineConfigSpecFluent.SourceNested editSource(){
            return withNewSourceLike(getSource());
    }

    public PipelineConfigSpecFluent.SourceNested editOrNewSource(){
            return withNewSourceLike(getSource() != null ? getSource(): new PipelineSourceBuilder().build());
    }

    public PipelineConfigSpecFluent.SourceNested editOrNewSourceLike(PipelineSource item){
            return withNewSourceLike(getSource() != null ? getSource(): item);
    }

    
/**
 * This method has been deprecated, please use method buildStrategy instead.
 */
@Deprecated public PipelineStrategy getStrategy(){
            return this.strategy!=null?this.strategy.build():null;
    }

    public PipelineStrategy buildStrategy(){
            return this.strategy!=null?this.strategy.build():null;
    }

    public A withStrategy(PipelineStrategy strategy){
            _visitables.remove(this.strategy);
            if (strategy!=null){ this.strategy= new PipelineStrategyBuilder(strategy); _visitables.add(this.strategy);} return (A) this;
    }

    public Boolean hasStrategy(){
            return this.strategy!=null;
    }

    public PipelineConfigSpecFluent.StrategyNested withNewStrategy(){
            return new StrategyNestedImpl();
    }

    public PipelineConfigSpecFluent.StrategyNested withNewStrategyLike(PipelineStrategy item){
            return new StrategyNestedImpl(item);
    }

    public PipelineConfigSpecFluent.StrategyNested editStrategy(){
            return withNewStrategyLike(getStrategy());
    }

    public PipelineConfigSpecFluent.StrategyNested editOrNewStrategy(){
            return withNewStrategyLike(getStrategy() != null ? getStrategy(): new PipelineStrategyBuilder().build());
    }

    public PipelineConfigSpecFluent.StrategyNested editOrNewStrategyLike(PipelineStrategy item){
            return withNewStrategyLike(getStrategy() != null ? getStrategy(): item);
    }

    public A addToTriggers(int index,PipelineTrigger item){
            PipelineTriggerBuilder builder = new PipelineTriggerBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.triggers.add(index >= 0 ? index : triggers.size(), builder); return (A)this;
    }

    public A setToTriggers(int index,PipelineTrigger item){
            PipelineTriggerBuilder builder = new PipelineTriggerBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= triggers.size()) { triggers.add(builder); } else { triggers.set(index, builder);}
             return (A)this;
    }

    public A addToTriggers(PipelineTrigger... items){
            for (PipelineTrigger item : items) {PipelineTriggerBuilder builder = new PipelineTriggerBuilder(item);_visitables.add(builder);this.triggers.add(builder);} return (A)this;
    }

    public A addAllToTriggers(Collection items){
            for (PipelineTrigger item : items) {PipelineTriggerBuilder builder = new PipelineTriggerBuilder(item);_visitables.add(builder);this.triggers.add(builder);} return (A)this;
    }

    public A removeFromTriggers(PipelineTrigger... items){
            for (PipelineTrigger item : items) {PipelineTriggerBuilder builder = new PipelineTriggerBuilder(item);_visitables.remove(builder);this.triggers.remove(builder);} return (A)this;
    }

    public A removeAllFromTriggers(Collection items){
            for (PipelineTrigger item : items) {PipelineTriggerBuilder builder = new PipelineTriggerBuilder(item);_visitables.remove(builder);this.triggers.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildTriggers instead.
 */
@Deprecated public List getTriggers(){
            return build(triggers);
    }

    public List buildTriggers(){
            return build(triggers);
    }

    public PipelineTrigger buildTrigger(int index){
            return this.triggers.get(index).build();
    }

    public PipelineTrigger buildFirstTrigger(){
            return this.triggers.get(0).build();
    }

    public PipelineTrigger buildLastTrigger(){
            return this.triggers.get(triggers.size() - 1).build();
    }

    public PipelineTrigger buildMatchingTrigger(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (PipelineTriggerBuilder item: triggers) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withTriggers(List triggers){
            _visitables.removeAll(this.triggers);
            this.triggers.clear();
            if (triggers != null) {for (PipelineTrigger item : triggers){this.addToTriggers(item);}} return (A) this;
    }

    public A withTriggers(PipelineTrigger... triggers){
            this.triggers.clear(); if (triggers != null) {for (PipelineTrigger item :triggers){ this.addToTriggers(item);}} return (A) this;
    }

    public Boolean hasTriggers(){
            return triggers!= null && !triggers.isEmpty();
    }

    public PipelineConfigSpecFluent.TriggersNested addNewTrigger(){
            return new TriggersNestedImpl();
    }

    public PipelineConfigSpecFluent.TriggersNested addNewTriggerLike(PipelineTrigger item){
            return new TriggersNestedImpl(-1, item);
    }

    public PipelineConfigSpecFluent.TriggersNested setNewTriggerLike(int index,PipelineTrigger item){
            return new TriggersNestedImpl(index, item);
    }

    public PipelineConfigSpecFluent.TriggersNested editTrigger(int index){
            if (triggers.size() <= index) throw new RuntimeException("Can't edit triggers. Index exceeds size.");
            return setNewTriggerLike(index, buildTrigger(index));
    }

    public PipelineConfigSpecFluent.TriggersNested editFirstTrigger(){
            if (triggers.size() == 0) throw new RuntimeException("Can't edit first triggers. The list is empty.");
            return setNewTriggerLike(0, buildTrigger(0));
    }

    public PipelineConfigSpecFluent.TriggersNested editLastTrigger(){
            int index = triggers.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last triggers. The list is empty.");
            return setNewTriggerLike(index, buildTrigger(index));
    }

    public PipelineConfigSpecFluent.TriggersNested editMatchingTrigger(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends PipelineHookFluentImpl> implements PipelineConfigSpecFluent.HooksNested,io.alauda.kubernetes.api.builder.Nested{

            private final PipelineHookBuilder builder;
        private final int index;
    
            HooksNestedImpl(int index,PipelineHook item){
                    this.index = index;
                    this.builder = new PipelineHookBuilder(this, item);
            }
            HooksNestedImpl(){
                    this.index = -1;
                    this.builder = new PipelineHookBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.setToHooks(index, builder.build());
    }
    public N endHook(){
            return and();
    }

}
    public class JenkinsBindingNestedImpl extends LocalObjectReferenceFluentImpl> implements PipelineConfigSpecFluent.JenkinsBindingNested,io.alauda.kubernetes.api.builder.Nested{

            private final LocalObjectReferenceBuilder builder;
    
            JenkinsBindingNestedImpl(LocalObjectReference item){
                    this.builder = new LocalObjectReferenceBuilder(this, item);
            }
            JenkinsBindingNestedImpl(){
                    this.builder = new LocalObjectReferenceBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.withJenkinsBinding(builder.build());
    }
    public N endJenkinsBinding(){
            return and();
    }

}
    public class ParametersNestedImpl extends PipelineParameterFluentImpl> implements PipelineConfigSpecFluent.ParametersNested,io.alauda.kubernetes.api.builder.Nested{

            private final PipelineParameterBuilder builder;
        private final int index;
    
            ParametersNestedImpl(int index,PipelineParameter item){
                    this.index = index;
                    this.builder = new PipelineParameterBuilder(this, item);
            }
            ParametersNestedImpl(){
                    this.index = -1;
                    this.builder = new PipelineParameterBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.setToParameters(index, builder.build());
    }
    public N endParameter(){
            return and();
    }

}
    public class RunLimitsNestedImpl extends PipelineRunLimitsFluentImpl> implements PipelineConfigSpecFluent.RunLimitsNested,io.alauda.kubernetes.api.builder.Nested{

            private final PipelineRunLimitsBuilder builder;
    
            RunLimitsNestedImpl(PipelineRunLimits item){
                    this.builder = new PipelineRunLimitsBuilder(this, item);
            }
            RunLimitsNestedImpl(){
                    this.builder = new PipelineRunLimitsBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.withRunLimits(builder.build());
    }
    public N endRunLimits(){
            return and();
    }

}
    public class SourceNestedImpl extends PipelineSourceFluentImpl> implements PipelineConfigSpecFluent.SourceNested,io.alauda.kubernetes.api.builder.Nested{

            private final PipelineSourceBuilder builder;
    
            SourceNestedImpl(PipelineSource item){
                    this.builder = new PipelineSourceBuilder(this, item);
            }
            SourceNestedImpl(){
                    this.builder = new PipelineSourceBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.withSource(builder.build());
    }
    public N endSource(){
            return and();
    }

}
    public class StrategyNestedImpl extends PipelineStrategyFluentImpl> implements PipelineConfigSpecFluent.StrategyNested,io.alauda.kubernetes.api.builder.Nested{

            private final PipelineStrategyBuilder builder;
    
            StrategyNestedImpl(PipelineStrategy item){
                    this.builder = new PipelineStrategyBuilder(this, item);
            }
            StrategyNestedImpl(){
                    this.builder = new PipelineStrategyBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.withStrategy(builder.build());
    }
    public N endStrategy(){
            return and();
    }

}
    public class TriggersNestedImpl extends PipelineTriggerFluentImpl> implements PipelineConfigSpecFluent.TriggersNested,io.alauda.kubernetes.api.builder.Nested{

            private final PipelineTriggerBuilder builder;
        private final int index;
    
            TriggersNestedImpl(int index,PipelineTrigger item){
                    this.index = index;
                    this.builder = new PipelineTriggerBuilder(this, item);
            }
            TriggersNestedImpl(){
                    this.index = -1;
                    this.builder = new PipelineTriggerBuilder(this);
            }
    
    public N and(){
            return (N) PipelineConfigSpecFluentImpl.this.setToTriggers(index, builder.build());
    }
    public N endTrigger(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy