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

io.alauda.kubernetes.api.model.PipelineDependencyFluentImpl 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 io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class PipelineDependencyFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PipelineDependencyFluent{

    private List plugins =  new ArrayList();

    public PipelineDependencyFluentImpl(){
    }
    public PipelineDependencyFluentImpl(PipelineDependency instance){
            this.withPlugins(instance.getPlugins()); 
    }

    public A addToPlugins(int index,JenkinsPlugin item){
            JenkinsPluginBuilder builder = new JenkinsPluginBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.plugins.add(index >= 0 ? index : plugins.size(), builder); return (A)this;
    }

    public A setToPlugins(int index,JenkinsPlugin item){
            JenkinsPluginBuilder builder = new JenkinsPluginBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= plugins.size()) { plugins.add(builder); } else { plugins.set(index, builder);}
             return (A)this;
    }

    public A addToPlugins(JenkinsPlugin... items){
            for (JenkinsPlugin item : items) {JenkinsPluginBuilder builder = new JenkinsPluginBuilder(item);_visitables.add(builder);this.plugins.add(builder);} return (A)this;
    }

    public A addAllToPlugins(Collection items){
            for (JenkinsPlugin item : items) {JenkinsPluginBuilder builder = new JenkinsPluginBuilder(item);_visitables.add(builder);this.plugins.add(builder);} return (A)this;
    }

    public A removeFromPlugins(JenkinsPlugin... items){
            for (JenkinsPlugin item : items) {JenkinsPluginBuilder builder = new JenkinsPluginBuilder(item);_visitables.remove(builder);this.plugins.remove(builder);} return (A)this;
    }

    public A removeAllFromPlugins(Collection items){
            for (JenkinsPlugin item : items) {JenkinsPluginBuilder builder = new JenkinsPluginBuilder(item);_visitables.remove(builder);this.plugins.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildPlugins instead.
 */
@Deprecated public List getPlugins(){
            return build(plugins);
    }

    public List buildPlugins(){
            return build(plugins);
    }

    public JenkinsPlugin buildPlugin(int index){
            return this.plugins.get(index).build();
    }

    public JenkinsPlugin buildFirstPlugin(){
            return this.plugins.get(0).build();
    }

    public JenkinsPlugin buildLastPlugin(){
            return this.plugins.get(plugins.size() - 1).build();
    }

    public JenkinsPlugin buildMatchingPlugin(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (JenkinsPluginBuilder item: plugins) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withPlugins(List plugins){
            _visitables.removeAll(this.plugins);
            this.plugins.clear();
            if (plugins != null) {for (JenkinsPlugin item : plugins){this.addToPlugins(item);}} return (A) this;
    }

    public A withPlugins(JenkinsPlugin... plugins){
            this.plugins.clear(); if (plugins != null) {for (JenkinsPlugin item :plugins){ this.addToPlugins(item);}} return (A) this;
    }

    public Boolean hasPlugins(){
            return plugins!= null && !plugins.isEmpty();
    }

    public PipelineDependencyFluent.PluginsNested addNewPlugin(){
            return new PluginsNestedImpl();
    }

    public PipelineDependencyFluent.PluginsNested addNewPluginLike(JenkinsPlugin item){
            return new PluginsNestedImpl(-1, item);
    }

    public PipelineDependencyFluent.PluginsNested setNewPluginLike(int index,JenkinsPlugin item){
            return new PluginsNestedImpl(index, item);
    }

    public PipelineDependencyFluent.PluginsNested editPlugin(int index){
            if (plugins.size() <= index) throw new RuntimeException("Can't edit plugins. Index exceeds size.");
            return setNewPluginLike(index, buildPlugin(index));
    }

    public PipelineDependencyFluent.PluginsNested editFirstPlugin(){
            if (plugins.size() == 0) throw new RuntimeException("Can't edit first plugins. The list is empty.");
            return setNewPluginLike(0, buildPlugin(0));
    }

    public PipelineDependencyFluent.PluginsNested editLastPlugin(){
            int index = plugins.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last plugins. The list is empty.");
            return setNewPluginLike(index, buildPlugin(index));
    }

    public PipelineDependencyFluent.PluginsNested editMatchingPlugin(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends JenkinsPluginFluentImpl> implements PipelineDependencyFluent.PluginsNested,io.alauda.kubernetes.api.builder.Nested{

            private final JenkinsPluginBuilder builder;
        private final int index;
    
            PluginsNestedImpl(int index,JenkinsPlugin item){
                    this.index = index;
                    this.builder = new JenkinsPluginBuilder(this, item);
            }
            PluginsNestedImpl(){
                    this.index = -1;
                    this.builder = new JenkinsPluginBuilder(this);
            }
    
    public N and(){
            return (N) PipelineDependencyFluentImpl.this.setToPlugins(index, builder.build());
    }
    public N endPlugin(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy