io.dekorate.openshift.config.OpenshiftConfigFluentImpl Maven / Gradle / Ivy
package io.dekorate.openshift.config;
import io.dekorate.deps.kubernetes.api.builder.VisitableBuilder;
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 io.dekorate.kubernetes.config.BaseConfigFluentImpl;
import java.lang.Boolean;
public class OpenshiftConfigFluentImpl> extends BaseConfigFluentImpl implements OpenshiftConfigFluent{
private boolean buildResourceGenerationEnabled = true;
private String builderImage = "fabric8/s2i-java:2.3";
private List buildEnvVars = new ArrayList();
private boolean autoBuildEnabled = false;
public OpenshiftConfigFluentImpl(){
}
public OpenshiftConfigFluentImpl(OpenshiftConfig instance){
this.withProject(instance.getProject());
this.withAttributes(instance.getAttributes());
this.withGroup(instance.getGroup());
this.withName(instance.getName());
this.withVersion(instance.getVersion());
this.withInitContainers(instance.getInitContainers());
this.withLabels(instance.getLabels());
this.withAnnotations(instance.getAnnotations());
this.withEnvVars(instance.getEnvVars());
this.withWorkingDir(instance.getWorkingDir());
this.withCommand(instance.getCommand());
this.withArguments(instance.getArguments());
this.withReplicas(instance.getReplicas());
this.withServiceAccount(instance.getServiceAccount());
this.withHost(instance.getHost());
this.withPorts(instance.getPorts());
this.withServiceType(instance.getServiceType());
this.withPvcVolumes(instance.getPvcVolumes());
this.withSecretVolumes(instance.getSecretVolumes());
this.withConfigMapVolumes(instance.getConfigMapVolumes());
this.withGitRepoVolumes(instance.getGitRepoVolumes());
this.withAwsElasticBlockStoreVolumes(instance.getAwsElasticBlockStoreVolumes());
this.withAzureDiskVolumes(instance.getAzureDiskVolumes());
this.withAzureFileVolumes(instance.getAzureFileVolumes());
this.withMounts(instance.getMounts());
this.withImagePullPolicy(instance.getImagePullPolicy());
this.withLivenessProbe(instance.getLivenessProbe());
this.withReadinessProbe(instance.getReadinessProbe());
this.withSidecars(instance.getSidecars());
this.withExpose(instance.isExpose());
this.withAutoDeployEnabled(instance.isAutoDeployEnabled());
this.withBuildResourceGenerationEnabled(instance.isBuildResourceGenerationEnabled());
this.withBuilderImage(instance.getBuilderImage());
this.withBuildEnvVars(instance.getBuildEnvVars());
this.withAutoBuildEnabled(instance.isAutoBuildEnabled());
}
public boolean isBuildResourceGenerationEnabled(){
return this.buildResourceGenerationEnabled;
}
public A withBuildResourceGenerationEnabled(boolean buildResourceGenerationEnabled){
this.buildResourceGenerationEnabled=buildResourceGenerationEnabled; return (A) this;
}
public Boolean hasBuildResourceGenerationEnabled(){
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 OpenshiftConfigFluent.ConfigBuildEnvVarsNested addNewConfigBuildEnvVar(){
return new ConfigBuildEnvVarsNestedImpl();
}
public OpenshiftConfigFluent.ConfigBuildEnvVarsNested addNewBuildEnvVarLike(io.dekorate.kubernetes.config.Env item){
return new ConfigBuildEnvVarsNestedImpl(-1, item);
}
public OpenshiftConfigFluent.ConfigBuildEnvVarsNested setNewBuildEnvVarLike(int index,io.dekorate.kubernetes.config.Env item){
return new ConfigBuildEnvVarsNestedImpl(index, item);
}
public OpenshiftConfigFluent.ConfigBuildEnvVarsNested editBuildEnvVar(int index){
if (buildEnvVars.size() <= index) throw new RuntimeException("Can't edit buildEnvVars. Index exceeds size.");
return setNewBuildEnvVarLike(index, buildBuildEnvVar(index));
}
public OpenshiftConfigFluent.ConfigBuildEnvVarsNested editFirstBuildEnvVar(){
if (buildEnvVars.size() == 0) throw new RuntimeException("Can't edit first buildEnvVars. The list is empty.");
return setNewBuildEnvVarLike(0, buildBuildEnvVar(0));
}
public OpenshiftConfigFluent.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 OpenshiftConfigFluent.ConfigBuildEnvVarsNested editMatchingBuildEnvVar(io.dekorate.deps.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends EnvFluentImpl> implements OpenshiftConfigFluent.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) OpenshiftConfigFluentImpl.this.setToBuildEnvVars(index, builder.build());
}
public N endConfigBuildEnvVar(){
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy