annotations.io.alauda.devops.api.model.CustomBuildStrategyFluentImpl Maven / Gradle / Ivy
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 CustomBuildStrategyFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements CustomBuildStrategyFluent{
private String buildAPIVersion;
private List env = new ArrayList();
private Boolean exposeDockerSocket;
private Boolean forcePull;
private ObjectReferenceBuilder from;
private LocalObjectReferenceBuilder pullSecret;
private List secrets = new ArrayList();
public CustomBuildStrategyFluentImpl(){
}
public CustomBuildStrategyFluentImpl(CustomBuildStrategy instance){
this.withBuildAPIVersion(instance.getBuildAPIVersion());
this.withEnv(instance.getEnv());
this.withExposeDockerSocket(instance.getExposeDockerSocket());
this.withForcePull(instance.getForcePull());
this.withFrom(instance.getFrom());
this.withPullSecret(instance.getPullSecret());
this.withSecrets(instance.getSecrets());
}
public String getBuildAPIVersion(){
return this.buildAPIVersion;
}
public A withBuildAPIVersion(String buildAPIVersion){
this.buildAPIVersion=buildAPIVersion; return (A) this;
}
public Boolean hasBuildAPIVersion(){
return this.buildAPIVersion!=null;
}
public A addToEnv(int index,EnvVar item){
EnvVarBuilder builder = new EnvVarBuilder(item);_visitables.add(index >= 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 CustomBuildStrategyFluent.EnvNested addNewEnv(){
return new EnvNestedImpl();
}
public CustomBuildStrategyFluent.EnvNested addNewEnvLike(EnvVar item){
return new EnvNestedImpl(-1, item);
}
public CustomBuildStrategyFluent.EnvNested setNewEnvLike(int index,EnvVar item){
return new EnvNestedImpl(index, item);
}
public CustomBuildStrategyFluent.EnvNested editEnv(int index){
if (env.size() <= index) throw new RuntimeException("Can't edit env. Index exceeds size.");
return setNewEnvLike(index, buildEnv(index));
}
public CustomBuildStrategyFluent.EnvNested editFirstEnv(){
if (env.size() == 0) throw new RuntimeException("Can't edit first env. The list is empty.");
return setNewEnvLike(0, buildEnv(0));
}
public CustomBuildStrategyFluent.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 CustomBuildStrategyFluent.EnvNested editMatchingEnv(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i withNewFrom(){
return new FromNestedImpl();
}
public CustomBuildStrategyFluent.FromNested withNewFromLike(ObjectReference item){
return new FromNestedImpl(item);
}
public CustomBuildStrategyFluent.FromNested editFrom(){
return withNewFromLike(getFrom());
}
public CustomBuildStrategyFluent.FromNested editOrNewFrom(){
return withNewFromLike(getFrom() != null ? getFrom(): new ObjectReferenceBuilder().build());
}
public CustomBuildStrategyFluent.FromNested editOrNewFromLike(ObjectReference item){
return withNewFromLike(getFrom() != null ? getFrom(): item);
}
/**
* 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 CustomBuildStrategyFluent.PullSecretNested withNewPullSecret(){
return new PullSecretNestedImpl();
}
public CustomBuildStrategyFluent.PullSecretNested withNewPullSecretLike(LocalObjectReference item){
return new PullSecretNestedImpl(item);
}
public CustomBuildStrategyFluent.PullSecretNested editPullSecret(){
return withNewPullSecretLike(getPullSecret());
}
public CustomBuildStrategyFluent.PullSecretNested editOrNewPullSecret(){
return withNewPullSecretLike(getPullSecret() != null ? getPullSecret(): new LocalObjectReferenceBuilder().build());
}
public CustomBuildStrategyFluent.PullSecretNested editOrNewPullSecretLike(LocalObjectReference item){
return withNewPullSecretLike(getPullSecret() != null ? getPullSecret(): item);
}
public A withNewPullSecret(String name){
return (A)withPullSecret(new LocalObjectReference(name));
}
public A addToSecrets(int index,SecretSpec item){
SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.secrets.add(index >= 0 ? index : secrets.size(), builder); return (A)this;
}
public A setToSecrets(int index,SecretSpec item){
SecretSpecBuilder builder = new SecretSpecBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= secrets.size()) { secrets.add(builder); } else { secrets.set(index, builder);}
return (A)this;
}
public A addToSecrets(SecretSpec... items){
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.add(builder);this.secrets.add(builder);} return (A)this;
}
public A addAllToSecrets(Collection items){
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.add(builder);this.secrets.add(builder);} return (A)this;
}
public A removeFromSecrets(SecretSpec... items){
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.remove(builder);this.secrets.remove(builder);} return (A)this;
}
public A removeAllFromSecrets(Collection items){
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.remove(builder);this.secrets.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildSecrets instead.
*/
@Deprecated public List getSecrets(){
return build(secrets);
}
public List buildSecrets(){
return build(secrets);
}
public SecretSpec buildSecret(int index){
return this.secrets.get(index).build();
}
public SecretSpec buildFirstSecret(){
return this.secrets.get(0).build();
}
public SecretSpec buildLastSecret(){
return this.secrets.get(secrets.size() - 1).build();
}
public SecretSpec buildMatchingSecret(io.alauda.kubernetes.api.builder.Predicate predicate){
for (SecretSpecBuilder item: secrets) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withSecrets(List secrets){
_visitables.removeAll(this.secrets);
this.secrets.clear();
if (secrets != null) {for (SecretSpec item : secrets){this.addToSecrets(item);}} return (A) this;
}
public A withSecrets(SecretSpec... secrets){
this.secrets.clear(); if (secrets != null) {for (SecretSpec item :secrets){ this.addToSecrets(item);}} return (A) this;
}
public Boolean hasSecrets(){
return secrets!= null && !secrets.isEmpty();
}
public CustomBuildStrategyFluent.SecretsNested addNewSecret(){
return new SecretsNestedImpl();
}
public CustomBuildStrategyFluent.SecretsNested addNewSecretLike(SecretSpec item){
return new SecretsNestedImpl(-1, item);
}
public CustomBuildStrategyFluent.SecretsNested setNewSecretLike(int index,SecretSpec item){
return new SecretsNestedImpl(index, item);
}
public CustomBuildStrategyFluent.SecretsNested editSecret(int index){
if (secrets.size() <= index) throw new RuntimeException("Can't edit secrets. Index exceeds size.");
return setNewSecretLike(index, buildSecret(index));
}
public CustomBuildStrategyFluent.SecretsNested editFirstSecret(){
if (secrets.size() == 0) throw new RuntimeException("Can't edit first secrets. The list is empty.");
return setNewSecretLike(0, buildSecret(0));
}
public CustomBuildStrategyFluent.SecretsNested editLastSecret(){
int index = secrets.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last secrets. The list is empty.");
return setNewSecretLike(index, buildSecret(index));
}
public CustomBuildStrategyFluent.SecretsNested editMatchingSecret(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends EnvVarFluentImpl> implements CustomBuildStrategyFluent.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) CustomBuildStrategyFluentImpl.this.setToEnv(index, builder.build());
}
public N endEnv(){
return and();
}
}
public class FromNestedImpl extends ObjectReferenceFluentImpl> implements CustomBuildStrategyFluent.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) CustomBuildStrategyFluentImpl.this.withFrom(builder.build());
}
public N endFrom(){
return and();
}
}
public class PullSecretNestedImpl extends LocalObjectReferenceFluentImpl> implements CustomBuildStrategyFluent.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) CustomBuildStrategyFluentImpl.this.withPullSecret(builder.build());
}
public N endPullSecret(){
return and();
}
}
public class SecretsNestedImpl extends SecretSpecFluentImpl> implements CustomBuildStrategyFluent.SecretsNested,io.alauda.kubernetes.api.builder.Nested{
private final SecretSpecBuilder builder;
private final int index;
SecretsNestedImpl(int index,SecretSpec item){
this.index = index;
this.builder = new SecretSpecBuilder(this, item);
}
SecretsNestedImpl(){
this.index = -1;
this.builder = new SecretSpecBuilder(this);
}
public N and(){
return (N) CustomBuildStrategyFluentImpl.this.setToSecrets(index, builder.build());
}
public N endSecret(){
return and();
}
}
}