io.dekorate.s2i.config.S2iBuildConfigFluentImpl Maven / Gradle / Ivy
package io.dekorate.s2i.config;
import io.dekorate.deps.kubernetes.api.builder.VisitableBuilder;
import io.dekorate.kubernetes.config.ImageConfigurationFluentImpl;
import java.lang.StringBuilder;
import io.dekorate.deps.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.dekorate.kubernetes.config.Env;
import io.dekorate.deps.kubernetes.api.builder.Predicate;
import java.lang.StringBuffer;
import io.dekorate.kubernetes.config.EnvBuilder;
import io.dekorate.kubernetes.config.EnvFluentImpl;
import java.lang.Deprecated;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class S2iBuildConfigFluentImpl> extends ImageConfigurationFluentImpl implements S2iBuildConfigFluent {
private boolean enabled = true;
private String builderImage = "fabric8/s2i-java:2.3";
private List buildEnvVars = new ArrayList();
private boolean autoDeployEnabled = false;
public S2iBuildConfigFluentImpl() {
}
public S2iBuildConfigFluentImpl(S2iBuildConfig instance) {
this.withProject(instance.getProject());
this.withAttributes(instance.getAttributes());
this.withRegistry(instance.getRegistry());
this.withGroup(instance.getGroup());
this.withName(instance.getName());
this.withVersion(instance.getVersion());
this.withImage(instance.getImage());
this.withDockerFile(instance.getDockerFile());
this.withAutoBuildEnabled(instance.isAutoBuildEnabled());
this.withAutoPushEnabled(instance.isAutoPushEnabled());
this.withEnabled(instance.isEnabled());
this.withBuilderImage(instance.getBuilderImage());
this.withBuildEnvVars(instance.getBuildEnvVars());
this.withAutoDeployEnabled(instance.isAutoDeployEnabled());
}
public boolean isEnabled() {
return this.enabled;
}
public A withEnabled(boolean enabled) {
this.enabled=enabled; return (A) this;
}
public Boolean hasEnabled() {
return true;
}
public String getBuilderImage() {
return this.builderImage;
}
public A withBuilderImage(String builderImage) {
this.builderImage=builderImage; return (A) this;
}
public Boolean hasBuilderImage() {
return this.builderImage != null;
}
public A withNewBuilderImage(String arg1) {
return (A)withBuilderImage(new String(arg1));
}
public A withNewBuilderImage(StringBuilder arg1) {
return (A)withBuilderImage(new String(arg1));
}
public A withNewBuilderImage(StringBuffer arg1) {
return (A)withBuilderImage(new String(arg1));
}
public A withBuildEnvVars(io.dekorate.kubernetes.config.Env... buildEnvVars) {
if (this.buildEnvVars != null) {this.buildEnvVars.clear();}
if (buildEnvVars != null) {for (io.dekorate.kubernetes.config.Env item :buildEnvVars){ this.addToBuildEnvVars(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildBuildEnvVars instead.
*/
@Deprecated public io.dekorate.kubernetes.config.Env[] getBuildEnvVars() {
int size = buildEnvVars != null ? buildEnvVars.size() : 0;
io.dekorate.kubernetes.config.Env[] result = new io.dekorate.kubernetes.config.Env[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.kubernetes.config.Env,?> builder : buildEnvVars) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.kubernetes.config.Env[] buildBuildEnvVars() {
int size = buildEnvVars != null ? buildEnvVars.size() : 0;
io.dekorate.kubernetes.config.Env[] result = new io.dekorate.kubernetes.config.Env[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.kubernetes.config.Env,?> builder : buildEnvVars) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.kubernetes.config.Env buildBuildEnvVar(int index) {
return this.buildEnvVars.get(index).build();
}
public io.dekorate.kubernetes.config.Env buildFirstBuildEnvVar() {
return this.buildEnvVars.get(0).build();
}
public io.dekorate.kubernetes.config.Env buildLastBuildEnvVar() {
return this.buildEnvVars.get(buildEnvVars.size() - 1).build();
}
public io.dekorate.kubernetes.config.Env buildMatchingBuildEnvVar(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (EnvBuilder item: buildEnvVars) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingBuildEnvVar(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (EnvBuilder item: buildEnvVars) { if(predicate.apply(item)){ return true;} } return false;
}
public A addToBuildEnvVars(int index,io.dekorate.kubernetes.config.Env item) {
if (this.buildEnvVars == null) {this.buildEnvVars = new ArrayList();}
io.dekorate.kubernetes.config.EnvBuilder builder = new io.dekorate.kubernetes.config.EnvBuilder(item);_visitables.get("buildEnvVars").add(index >= 0 ? index : _visitables.get("buildEnvVars").size(), builder);this.buildEnvVars.add(index >= 0 ? index : buildEnvVars.size(), builder); return (A)this;
}
public A setToBuildEnvVars(int index,io.dekorate.kubernetes.config.Env item) {
if (this.buildEnvVars == null) {this.buildEnvVars = new ArrayList();}
io.dekorate.kubernetes.config.EnvBuilder builder = new io.dekorate.kubernetes.config.EnvBuilder(item);
if (index < 0 || index >= _visitables.get("buildEnvVars").size()) { _visitables.get("buildEnvVars").add(builder); } else { _visitables.get("buildEnvVars").set(index, builder);}
if (index < 0 || index >= buildEnvVars.size()) { buildEnvVars.add(builder); } else { buildEnvVars.set(index, builder);}
return (A)this;
}
public A addToBuildEnvVars(io.dekorate.kubernetes.config.Env... items) {
if (this.buildEnvVars == null) {this.buildEnvVars = new ArrayList();}
for (io.dekorate.kubernetes.config.Env item : items) {io.dekorate.kubernetes.config.EnvBuilder builder = new io.dekorate.kubernetes.config.EnvBuilder(item);_visitables.get("buildEnvVars").add(builder);this.buildEnvVars.add(builder);} return (A)this;
}
public A addAllToConfigBuildEnvVars(Collection items) {
if (this.buildEnvVars == null) {this.buildEnvVars = new ArrayList();}
for (io.dekorate.kubernetes.config.Env item : items) {io.dekorate.kubernetes.config.EnvBuilder builder = new io.dekorate.kubernetes.config.EnvBuilder(item);_visitables.get("buildEnvVars").add(builder);this.buildEnvVars.add(builder);} return (A)this;
}
public A removeFromBuildEnvVars(io.dekorate.kubernetes.config.Env... items) {
for (io.dekorate.kubernetes.config.Env item : items) {io.dekorate.kubernetes.config.EnvBuilder builder = new io.dekorate.kubernetes.config.EnvBuilder(item);_visitables.get("buildEnvVars").remove(builder);if (this.buildEnvVars != null) {this.buildEnvVars.remove(builder);}} return (A)this;
}
public A removeAllFromConfigBuildEnvVars(Collection items) {
for (io.dekorate.kubernetes.config.Env item : items) {io.dekorate.kubernetes.config.EnvBuilder builder = new io.dekorate.kubernetes.config.EnvBuilder(item);_visitables.get("buildEnvVars").remove(builder);if (this.buildEnvVars != null) {this.buildEnvVars.remove(builder);}} return (A)this;
}
public A removeMatchingFromConfigBuildEnvVars(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
if (buildEnvVars == null) return (A) this;
final Iterator each = buildEnvVars.iterator();
final List visitables = _visitables.get("buildEnvVars");
while (each.hasNext()) {
EnvBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasBuildEnvVars() {
return buildEnvVars != null && !buildEnvVars.isEmpty();
}
public A addNewConfigBuildEnvVar(String name,String value,String secret,String configmap,String field) {
return (A)addToBuildEnvVars(new Env(name, value, secret, configmap, field));
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested addNewConfigBuildEnvVar() {
return new ConfigBuildEnvVarsNestedImpl();
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested addNewBuildEnvVarLike(io.dekorate.kubernetes.config.Env item) {
return new ConfigBuildEnvVarsNestedImpl(-1, item);
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested setNewBuildEnvVarLike(int index,io.dekorate.kubernetes.config.Env item) {
return new ConfigBuildEnvVarsNestedImpl(index, item);
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested editBuildEnvVar(int index) {
if (buildEnvVars.size() <= index) throw new RuntimeException("Can't edit buildEnvVars. Index exceeds size.");
return setNewBuildEnvVarLike(index, buildBuildEnvVar(index));
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested editFirstBuildEnvVar() {
if (buildEnvVars.size() == 0) throw new RuntimeException("Can't edit first buildEnvVars. The list is empty.");
return setNewBuildEnvVarLike(0, buildBuildEnvVar(0));
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested editLastBuildEnvVar() {
int index = buildEnvVars.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last buildEnvVars. The list is empty.");
return setNewBuildEnvVarLike(index, buildBuildEnvVar(index));
}
public S2iBuildConfigFluent.ConfigBuildEnvVarsNested editMatchingBuildEnvVar(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
int index = -1;
for (int i=0;i extends EnvFluentImpl> implements S2iBuildConfigFluent.ConfigBuildEnvVarsNested,io.dekorate.deps.kubernetes.api.builder.Nested {
private final EnvBuilder builder;
private final int index;
ConfigBuildEnvVarsNestedImpl(int index,io.dekorate.kubernetes.config.Env item) {
this.index = index;
this.builder = new EnvBuilder(this, item);
}
ConfigBuildEnvVarsNestedImpl() {
this.index = -1;
this.builder = new EnvBuilder(this);
}
public N and() {
return (N) S2iBuildConfigFluentImpl.this.setToBuildEnvVars(index,builder.build());
}
public N endConfigBuildEnvVar() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy