io.alauda.devops.api.model.DeploymentConfigSpecFluentImpl Maven / Gradle / Ivy
package io.alauda.devops.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.model.PodTemplateSpecFluentImpl;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.alauda.kubernetes.api.builder.Predicate;
import java.util.LinkedHashMap;
import io.alauda.kubernetes.api.model.PodTemplateSpec;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.List;
import java.lang.Boolean;
import java.lang.Integer;
import javax.validation.Valid;
import io.alauda.kubernetes.api.model.PodTemplateSpecBuilder;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;
public class DeploymentConfigSpecFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements DeploymentConfigSpecFluent{
private Integer minReadySeconds;
private Boolean paused;
private Integer replicas;
private Integer revisionHistoryLimit;
private Map selector = new LinkedHashMap();
private DeploymentStrategyBuilder strategy;
private PodTemplateSpecBuilder template;
private Boolean test;
private List triggers = new ArrayList();
public DeploymentConfigSpecFluentImpl(){
}
public DeploymentConfigSpecFluentImpl(DeploymentConfigSpec instance){
this.withMinReadySeconds(instance.getMinReadySeconds());
this.withPaused(instance.getPaused());
this.withReplicas(instance.getReplicas());
this.withRevisionHistoryLimit(instance.getRevisionHistoryLimit());
this.withSelector(instance.getSelector());
this.withStrategy(instance.getStrategy());
this.withTemplate(instance.getTemplate());
this.withTest(instance.getTest());
this.withTriggers(instance.getTriggers());
}
public Integer getMinReadySeconds(){
return this.minReadySeconds;
}
public A withMinReadySeconds(Integer minReadySeconds){
this.minReadySeconds=minReadySeconds; return (A) this;
}
public Boolean hasMinReadySeconds(){
return this.minReadySeconds!=null;
}
public Boolean isPaused(){
return this.paused;
}
public A withPaused(Boolean paused){
this.paused=paused; return (A) this;
}
public Boolean hasPaused(){
return this.paused!=null;
}
public Integer getReplicas(){
return this.replicas;
}
public A withReplicas(Integer replicas){
this.replicas=replicas; return (A) this;
}
public Boolean hasReplicas(){
return this.replicas!=null;
}
public Integer getRevisionHistoryLimit(){
return this.revisionHistoryLimit;
}
public A withRevisionHistoryLimit(Integer revisionHistoryLimit){
this.revisionHistoryLimit=revisionHistoryLimit; return (A) this;
}
public Boolean hasRevisionHistoryLimit(){
return this.revisionHistoryLimit!=null;
}
public A addToSelector(String key,String value){
if(key != null && value != null) {this.selector.put(key, value);} return (A)this;
}
public A addToSelector(Map map){
if(map != null) { this.selector.putAll(map);} return (A)this;
}
public A removeFromSelector(String key){
if(key != null) {this.selector.remove(key);} return (A)this;
}
public A removeFromSelector(Map map){
if(map != null) { for(Object key : map.keySet()) {this.selector.remove(key);}} return (A)this;
}
public Map getSelector(){
return this.selector;
}
public A withSelector(Map selector){
this.selector.clear();
if (selector != null) {this.selector.putAll(selector);} return (A) this;
}
public Boolean hasSelector(){
return this.selector!=null;
}
/**
* This method has been deprecated, please use method buildStrategy instead.
*/
@Deprecated public DeploymentStrategy getStrategy(){
return this.strategy!=null?this.strategy.build():null;
}
public DeploymentStrategy buildStrategy(){
return this.strategy!=null?this.strategy.build():null;
}
public A withStrategy(DeploymentStrategy strategy){
_visitables.remove(this.strategy);
if (strategy!=null){ this.strategy= new DeploymentStrategyBuilder(strategy); _visitables.add(this.strategy);} return (A) this;
}
public Boolean hasStrategy(){
return this.strategy!=null;
}
public DeploymentConfigSpecFluent.StrategyNested withNewStrategy(){
return new StrategyNestedImpl();
}
public DeploymentConfigSpecFluent.StrategyNested withNewStrategyLike(DeploymentStrategy item){
return new StrategyNestedImpl(item);
}
public DeploymentConfigSpecFluent.StrategyNested editStrategy(){
return withNewStrategyLike(getStrategy());
}
public DeploymentConfigSpecFluent.StrategyNested editOrNewStrategy(){
return withNewStrategyLike(getStrategy() != null ? getStrategy(): new DeploymentStrategyBuilder().build());
}
public DeploymentConfigSpecFluent.StrategyNested editOrNewStrategyLike(DeploymentStrategy item){
return withNewStrategyLike(getStrategy() != null ? getStrategy(): item);
}
/**
* This method has been deprecated, please use method buildTemplate instead.
*/
@Deprecated public PodTemplateSpec getTemplate(){
return this.template!=null?this.template.build():null;
}
public PodTemplateSpec buildTemplate(){
return this.template!=null?this.template.build():null;
}
public A withTemplate(PodTemplateSpec template){
_visitables.remove(this.template);
if (template!=null){ this.template= new PodTemplateSpecBuilder(template); _visitables.add(this.template);} return (A) this;
}
public Boolean hasTemplate(){
return this.template!=null;
}
public DeploymentConfigSpecFluent.TemplateNested withNewTemplate(){
return new TemplateNestedImpl();
}
public DeploymentConfigSpecFluent.TemplateNested withNewTemplateLike(PodTemplateSpec item){
return new TemplateNestedImpl(item);
}
public DeploymentConfigSpecFluent.TemplateNested editTemplate(){
return withNewTemplateLike(getTemplate());
}
public DeploymentConfigSpecFluent.TemplateNested editOrNewTemplate(){
return withNewTemplateLike(getTemplate() != null ? getTemplate(): new PodTemplateSpecBuilder().build());
}
public DeploymentConfigSpecFluent.TemplateNested editOrNewTemplateLike(PodTemplateSpec item){
return withNewTemplateLike(getTemplate() != null ? getTemplate(): item);
}
public Boolean isTest(){
return this.test;
}
public A withTest(Boolean test){
this.test=test; return (A) this;
}
public Boolean hasTest(){
return this.test!=null;
}
public A addToTriggers(int index,DeploymentTriggerPolicy item){
DeploymentTriggerPolicyBuilder builder = new DeploymentTriggerPolicyBuilder(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,DeploymentTriggerPolicy item){
DeploymentTriggerPolicyBuilder builder = new DeploymentTriggerPolicyBuilder(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(DeploymentTriggerPolicy... items){
for (DeploymentTriggerPolicy item : items) {DeploymentTriggerPolicyBuilder builder = new DeploymentTriggerPolicyBuilder(item);_visitables.add(builder);this.triggers.add(builder);} return (A)this;
}
public A addAllToTriggers(Collection items){
for (DeploymentTriggerPolicy item : items) {DeploymentTriggerPolicyBuilder builder = new DeploymentTriggerPolicyBuilder(item);_visitables.add(builder);this.triggers.add(builder);} return (A)this;
}
public A removeFromTriggers(DeploymentTriggerPolicy... items){
for (DeploymentTriggerPolicy item : items) {DeploymentTriggerPolicyBuilder builder = new DeploymentTriggerPolicyBuilder(item);_visitables.remove(builder);this.triggers.remove(builder);} return (A)this;
}
public A removeAllFromTriggers(Collection items){
for (DeploymentTriggerPolicy item : items) {DeploymentTriggerPolicyBuilder builder = new DeploymentTriggerPolicyBuilder(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 DeploymentTriggerPolicy buildTrigger(int index){
return this.triggers.get(index).build();
}
public DeploymentTriggerPolicy buildFirstTrigger(){
return this.triggers.get(0).build();
}
public DeploymentTriggerPolicy buildLastTrigger(){
return this.triggers.get(triggers.size() - 1).build();
}
public DeploymentTriggerPolicy buildMatchingTrigger(io.alauda.kubernetes.api.builder.Predicate predicate){
for (DeploymentTriggerPolicyBuilder 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 (DeploymentTriggerPolicy item : triggers){this.addToTriggers(item);}} return (A) this;
}
public A withTriggers(DeploymentTriggerPolicy... triggers){
this.triggers.clear(); if (triggers != null) {for (DeploymentTriggerPolicy item :triggers){ this.addToTriggers(item);}} return (A) this;
}
public Boolean hasTriggers(){
return triggers!= null && !triggers.isEmpty();
}
public DeploymentConfigSpecFluent.TriggersNested addNewTrigger(){
return new TriggersNestedImpl();
}
public DeploymentConfigSpecFluent.TriggersNested addNewTriggerLike(DeploymentTriggerPolicy item){
return new TriggersNestedImpl(-1, item);
}
public DeploymentConfigSpecFluent.TriggersNested setNewTriggerLike(int index,DeploymentTriggerPolicy item){
return new TriggersNestedImpl(index, item);
}
public DeploymentConfigSpecFluent.TriggersNested editTrigger(int index){
if (triggers.size() <= index) throw new RuntimeException("Can't edit triggers. Index exceeds size.");
return setNewTriggerLike(index, buildTrigger(index));
}
public DeploymentConfigSpecFluent.TriggersNested editFirstTrigger(){
if (triggers.size() == 0) throw new RuntimeException("Can't edit first triggers. The list is empty.");
return setNewTriggerLike(0, buildTrigger(0));
}
public DeploymentConfigSpecFluent.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 DeploymentConfigSpecFluent.TriggersNested editMatchingTrigger(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends DeploymentStrategyFluentImpl> implements DeploymentConfigSpecFluent.StrategyNested,io.alauda.kubernetes.api.builder.Nested{
private final DeploymentStrategyBuilder builder;
StrategyNestedImpl(DeploymentStrategy item){
this.builder = new DeploymentStrategyBuilder(this, item);
}
StrategyNestedImpl(){
this.builder = new DeploymentStrategyBuilder(this);
}
public N and(){
return (N) DeploymentConfigSpecFluentImpl.this.withStrategy(builder.build());
}
public N endStrategy(){
return and();
}
}
public class TemplateNestedImpl extends PodTemplateSpecFluentImpl> implements DeploymentConfigSpecFluent.TemplateNested,io.alauda.kubernetes.api.builder.Nested{
private final PodTemplateSpecBuilder builder;
TemplateNestedImpl(PodTemplateSpec item){
this.builder = new PodTemplateSpecBuilder(this, item);
}
TemplateNestedImpl(){
this.builder = new PodTemplateSpecBuilder(this);
}
public N and(){
return (N) DeploymentConfigSpecFluentImpl.this.withTemplate(builder.build());
}
public N endTemplate(){
return and();
}
}
public class TriggersNestedImpl extends DeploymentTriggerPolicyFluentImpl> implements DeploymentConfigSpecFluent.TriggersNested,io.alauda.kubernetes.api.builder.Nested{
private final DeploymentTriggerPolicyBuilder builder;
private final int index;
TriggersNestedImpl(int index,DeploymentTriggerPolicy item){
this.index = index;
this.builder = new DeploymentTriggerPolicyBuilder(this, item);
}
TriggersNestedImpl(){
this.index = -1;
this.builder = new DeploymentTriggerPolicyBuilder(this);
}
public N and(){
return (N) DeploymentConfigSpecFluentImpl.this.setToTriggers(index, builder.build());
}
public N endTrigger(){
return and();
}
}
}