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

io.alauda.devops.api.model.CustomDeploymentStrategyParamsFluentImpl 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 CustomDeploymentStrategyParamsFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements CustomDeploymentStrategyParamsFluent{

    private List command = new ArrayList();
    private List environment =  new ArrayList();
    private String image;

    public CustomDeploymentStrategyParamsFluentImpl(){
    }
    public CustomDeploymentStrategyParamsFluentImpl(CustomDeploymentStrategyParams instance){
            this.withCommand(instance.getCommand()); 
            this.withEnvironment(instance.getEnvironment()); 
            this.withImage(instance.getImage()); 
    }

    public A addToCommand(int index,String item){
            this.command.add(index, item); return (A)this;
    }

    public A setToCommand(int index,String item){
            this.command.set(index, item); return (A)this;
    }

    public A addToCommand(String... items){
            for (String item : items) {this.command.add(item);} return (A)this;
    }

    public A addAllToCommand(Collection items){
            for (String item : items) {this.command.add(item);} return (A)this;
    }

    public A removeFromCommand(String... items){
            for (String item : items) {this.command.remove(item);} return (A)this;
    }

    public A removeAllFromCommand(Collection items){
            for (String item : items) {this.command.remove(item);} return (A)this;
    }

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

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

    public String getFirstCommand(){
            return this.command.get(0);
    }

    public String getLastCommand(){
            return this.command.get(command.size() - 1);
    }

    public String getMatchingCommand(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (String item: command) { if(predicate.apply(item)){return item;} } return null;
    }

    public A withCommand(List command){
            this.command.clear();
            if (command != null) {for (String item : command){this.addToCommand(item);}} return (A) this;
    }

    public A withCommand(String... command){
            this.command.clear(); if (command != null) {for (String item :command){ this.addToCommand(item);}} return (A) this;
    }

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

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

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

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

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

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

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

    
/**
 * This method has been deprecated, please use method buildEnvironment instead.
 */
@Deprecated public List getEnvironment(){
            return build(environment);
    }

    public List buildEnvironment(){
            return build(environment);
    }

    public EnvVar buildEnvironment(int index){
            return this.environment.get(index).build();
    }

    public EnvVar buildFirstEnvironment(){
            return this.environment.get(0).build();
    }

    public EnvVar buildLastEnvironment(){
            return this.environment.get(environment.size() - 1).build();
    }

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

    public A withEnvironment(List environment){
            _visitables.removeAll(this.environment);
            this.environment.clear();
            if (environment != null) {for (EnvVar item : environment){this.addToEnvironment(item);}} return (A) this;
    }

    public A withEnvironment(EnvVar... environment){
            this.environment.clear(); if (environment != null) {for (EnvVar item :environment){ this.addToEnvironment(item);}} return (A) this;
    }

    public Boolean hasEnvironment(){
            return environment!= null && !environment.isEmpty();
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested addNewEnvironment(){
            return new EnvironmentNestedImpl();
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested addNewEnvironmentLike(EnvVar item){
            return new EnvironmentNestedImpl(-1, item);
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested setNewEnvironmentLike(int index,EnvVar item){
            return new EnvironmentNestedImpl(index, item);
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested editEnvironment(int index){
            if (environment.size() <= index) throw new RuntimeException("Can't edit environment. Index exceeds size.");
            return setNewEnvironmentLike(index, buildEnvironment(index));
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested editFirstEnvironment(){
            if (environment.size() == 0) throw new RuntimeException("Can't edit first environment. The list is empty.");
            return setNewEnvironmentLike(0, buildEnvironment(0));
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested editLastEnvironment(){
            int index = environment.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last environment. The list is empty.");
            return setNewEnvironmentLike(index, buildEnvironment(index));
    }

    public CustomDeploymentStrategyParamsFluent.EnvironmentNested editMatchingEnvironment(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends EnvVarFluentImpl> implements CustomDeploymentStrategyParamsFluent.EnvironmentNested,io.alauda.kubernetes.api.builder.Nested{

            private final EnvVarBuilder builder;
        private final int index;
    
            EnvironmentNestedImpl(int index,EnvVar item){
                    this.index = index;
                    this.builder = new EnvVarBuilder(this, item);
            }
            EnvironmentNestedImpl(){
                    this.index = -1;
                    this.builder = new EnvVarBuilder(this);
            }
    
    public N and(){
            return (N) CustomDeploymentStrategyParamsFluentImpl.this.setToEnvironment(index, builder.build());
    }
    public N endEnvironment(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy