io.dekorate.openshift.config.OpenshiftConfigFluentImpl Maven / Gradle / Ivy
package io.dekorate.openshift.config;
import io.dekorate.deps.kubernetes.api.builder.VisitableBuilder;
import io.dekorate.deps.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.dekorate.kubernetes.config.ContainerFluentImpl;
import io.dekorate.deps.kubernetes.api.builder.Predicate;
import io.dekorate.kubernetes.config.Container;
import io.dekorate.kubernetes.config.ContainerBuilder;
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 List initContainers = new ArrayList();
private int replicas = 1;
private boolean headless = false;
public OpenshiftConfigFluentImpl() {
}
public OpenshiftConfigFluentImpl(OpenshiftConfig instance) {
this.withProject(instance.getProject());
this.withAttributes(instance.getAttributes());
this.withPartOf(instance.getPartOf());
this.withName(instance.getName());
this.withVersion(instance.getVersion());
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.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.withImagePullSecrets(instance.getImagePullSecrets());
this.withHostAliases(instance.getHostAliases());
this.withLivenessProbe(instance.getLivenessProbe());
this.withReadinessProbe(instance.getReadinessProbe());
this.withRequestResources(instance.getRequestResources());
this.withLimitResources(instance.getLimitResources());
this.withSidecars(instance.getSidecars());
this.withExpose(instance.isExpose());
this.withAutoDeployEnabled(instance.isAutoDeployEnabled());
this.withInitContainers(instance.getInitContainers());
this.withReplicas(instance.getReplicas());
this.withHeadless(instance.isHeadless());
}
public A withInitContainers(io.dekorate.kubernetes.config.Container... initContainers) {
if (this.initContainers != null) {this.initContainers.clear();}
if (initContainers != null) {for (io.dekorate.kubernetes.config.Container item :initContainers){ this.addToInitContainers(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildInitContainers instead.
*/
@Deprecated public io.dekorate.kubernetes.config.Container[] getInitContainers() {
int size = initContainers != null ? initContainers.size() : 0;
io.dekorate.kubernetes.config.Container[] result = new io.dekorate.kubernetes.config.Container[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.kubernetes.config.Container,?> builder : initContainers) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.kubernetes.config.Container[] buildInitContainers() {
int size = initContainers != null ? initContainers.size() : 0;
io.dekorate.kubernetes.config.Container[] result = new io.dekorate.kubernetes.config.Container[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.kubernetes.config.Container,?> builder : initContainers) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.kubernetes.config.Container buildInitContainer(int index) {
return this.initContainers.get(index).build();
}
public io.dekorate.kubernetes.config.Container buildFirstInitContainer() {
return this.initContainers.get(0).build();
}
public io.dekorate.kubernetes.config.Container buildLastInitContainer() {
return this.initContainers.get(initContainers.size() - 1).build();
}
public io.dekorate.kubernetes.config.Container buildMatchingInitContainer(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (ContainerBuilder item: initContainers) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingInitContainer(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (ContainerBuilder item: initContainers) { if(predicate.apply(item)){ return true;} } return false;
}
public A addToInitContainers(int index,io.dekorate.kubernetes.config.Container item) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
io.dekorate.kubernetes.config.ContainerBuilder builder = new io.dekorate.kubernetes.config.ContainerBuilder(item);_visitables.get("initContainers").add(index >= 0 ? index : _visitables.get("initContainers").size(), builder);this.initContainers.add(index >= 0 ? index : initContainers.size(), builder); return (A)this;
}
public A setToInitContainers(int index,io.dekorate.kubernetes.config.Container item) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
io.dekorate.kubernetes.config.ContainerBuilder builder = new io.dekorate.kubernetes.config.ContainerBuilder(item);
if (index < 0 || index >= _visitables.get("initContainers").size()) { _visitables.get("initContainers").add(builder); } else { _visitables.get("initContainers").set(index, builder);}
if (index < 0 || index >= initContainers.size()) { initContainers.add(builder); } else { initContainers.set(index, builder);}
return (A)this;
}
public A addToInitContainers(io.dekorate.kubernetes.config.Container... items) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
for (io.dekorate.kubernetes.config.Container item : items) {io.dekorate.kubernetes.config.ContainerBuilder builder = new io.dekorate.kubernetes.config.ContainerBuilder(item);_visitables.get("initContainers").add(builder);this.initContainers.add(builder);} return (A)this;
}
public A addAllToConfigInitContainers(Collection items) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
for (io.dekorate.kubernetes.config.Container item : items) {io.dekorate.kubernetes.config.ContainerBuilder builder = new io.dekorate.kubernetes.config.ContainerBuilder(item);_visitables.get("initContainers").add(builder);this.initContainers.add(builder);} return (A)this;
}
public A removeFromInitContainers(io.dekorate.kubernetes.config.Container... items) {
for (io.dekorate.kubernetes.config.Container item : items) {io.dekorate.kubernetes.config.ContainerBuilder builder = new io.dekorate.kubernetes.config.ContainerBuilder(item);_visitables.get("initContainers").remove(builder);if (this.initContainers != null) {this.initContainers.remove(builder);}} return (A)this;
}
public A removeAllFromConfigInitContainers(Collection items) {
for (io.dekorate.kubernetes.config.Container item : items) {io.dekorate.kubernetes.config.ContainerBuilder builder = new io.dekorate.kubernetes.config.ContainerBuilder(item);_visitables.get("initContainers").remove(builder);if (this.initContainers != null) {this.initContainers.remove(builder);}} return (A)this;
}
public A removeMatchingFromConfigInitContainers(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
if (initContainers == null) return (A) this;
final Iterator each = initContainers.iterator();
final List visitables = _visitables.get("initContainers");
while (each.hasNext()) {
ContainerBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasInitContainers() {
return initContainers != null && !initContainers.isEmpty();
}
public OpenshiftConfigFluent.ConfigInitContainersNested addNewConfigInitContainer() {
return new ConfigInitContainersNestedImpl();
}
public OpenshiftConfigFluent.ConfigInitContainersNested addNewInitContainerLike(io.dekorate.kubernetes.config.Container item) {
return new ConfigInitContainersNestedImpl(-1, item);
}
public OpenshiftConfigFluent.ConfigInitContainersNested setNewInitContainerLike(int index,io.dekorate.kubernetes.config.Container item) {
return new ConfigInitContainersNestedImpl(index, item);
}
public OpenshiftConfigFluent.ConfigInitContainersNested editInitContainer(int index) {
if (initContainers.size() <= index) throw new RuntimeException("Can't edit initContainers. Index exceeds size.");
return setNewInitContainerLike(index, buildInitContainer(index));
}
public OpenshiftConfigFluent.ConfigInitContainersNested editFirstInitContainer() {
if (initContainers.size() == 0) throw new RuntimeException("Can't edit first initContainers. The list is empty.");
return setNewInitContainerLike(0, buildInitContainer(0));
}
public OpenshiftConfigFluent.ConfigInitContainersNested editLastInitContainer() {
int index = initContainers.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last initContainers. The list is empty.");
return setNewInitContainerLike(index, buildInitContainer(index));
}
public OpenshiftConfigFluent.ConfigInitContainersNested editMatchingInitContainer(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
int index = -1;
for (int i=0;i extends ContainerFluentImpl> implements OpenshiftConfigFluent.ConfigInitContainersNested,io.dekorate.deps.kubernetes.api.builder.Nested {
private final ContainerBuilder builder;
private final int index;
ConfigInitContainersNestedImpl(int index,io.dekorate.kubernetes.config.Container item) {
this.index = index;
this.builder = new ContainerBuilder(this, item);
}
ConfigInitContainersNestedImpl() {
this.index = -1;
this.builder = new ContainerBuilder(this);
}
public N and() {
return (N) OpenshiftConfigFluentImpl.this.setToInitContainers(index,builder.build());
}
public N endConfigInitContainer() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy