io.dekorate.openshift.config.OpenshiftConfigFluent Maven / Gradle / Ivy
package io.dekorate.openshift.config;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.function.Predicate;
import io.dekorate.kubernetes.config.Container;
import io.dekorate.kubernetes.config.ContainerBuilder;
import io.dekorate.kubernetes.config.ContainerFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import io.dekorate.kubernetes.config.BaseConfigFluent;
import java.lang.Integer;
import java.util.Collection;
import java.lang.Object;
/**
* Generated
*/
@SuppressWarnings("unchecked")
public class OpenshiftConfigFluent> extends BaseConfigFluent{
public OpenshiftConfigFluent() {
}
public OpenshiftConfigFluent(OpenshiftConfig instance) {
this.copyInstance(instance);
}
private ArrayList initContainers = new ArrayList();
private Integer replicas;
private RouteBuilder route;
private Boolean headless;
protected void copyInstance(OpenshiftConfig instance) {
instance = (instance != null ? instance : new OpenshiftConfig());
if (instance != null) {
this.withProject(instance.getProject());
this.withAttributes(instance.getAttributes());
this.withPartOf(instance.getPartOf());
this.withName(instance.getName());
this.withVersion(instance.getVersion());
this.withDeploymentKind(instance.getDeploymentKind());
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.withPorts(instance.getPorts());
this.withServiceType(instance.getServiceType());
this.withPvcVolumes(instance.getPvcVolumes());
this.withSecretVolumes(instance.getSecretVolumes());
this.withConfigMapVolumes(instance.getConfigMapVolumes());
this.withEmptyDirVolumes(instance.getEmptyDirVolumes());
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.withDeploymentStrategy(instance.getDeploymentStrategy());
this.withRollingUpdate(instance.getRollingUpdate());
this.withHostAliases(instance.getHostAliases());
this.withLivenessProbe(instance.getLivenessProbe());
this.withReadinessProbe(instance.getReadinessProbe());
this.withStartupProbe(instance.getStartupProbe());
this.withRequestResources(instance.getRequestResources());
this.withLimitResources(instance.getLimitResources());
this.withSidecars(instance.getSidecars());
this.withAutoDeployEnabled(instance.getAutoDeployEnabled());
this.withJobs(instance.getJobs());
this.withCronJobs(instance.getCronJobs());
this.withInitContainers(instance.getInitContainers());
this.withReplicas(instance.getReplicas());
this.withRoute(instance.getRoute());
this.withHeadless(instance.getHeadless());
}
}
public A withInitContainers(io.dekorate.kubernetes.config.Container... initContainers) {
if (this.initContainers != null) {
this.initContainers.clear();
_visitables.remove("initContainers");
}
if (initContainers != null) {
for (Container item : initContainers) {
this.addToInitContainers(item);
}
}
return (A) this;
}
public Container[] buildInitContainers() {
int size = initContainers != null ? initContainers.size() : 0;;
Container[] result = new Container[size];;
if (size == 0) {
return result;
}
int index = 0;;
for (VisitableBuilder item : initContainers) {
result[index++] = item.build();
}
return result;
}
public Container buildInitContainer(int index) {
return this.initContainers.get(index).build();
}
public Container buildFirstInitContainer() {
return this.initContainers.get(0).build();
}
public Container buildLastInitContainer() {
return this.initContainers.get(initContainers.size() - 1).build();
}
public Container buildMatchingInitContainer(Predicate predicate) {
for (ContainerBuilder item : initContainers) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingInitContainer(Predicate predicate) {
for (ContainerBuilder item : initContainers) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A addToInitContainers(int index,Container item) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
ContainerBuilder builder = new ContainerBuilder(item);
if (index < 0 || index >= initContainers.size()) { _visitables.get("initContainers").add(builder); initContainers.add(builder); } else { _visitables.get("initContainers").add(index, builder); initContainers.add(index, builder);}
return (A)this;
}
public A setToInitContainers(int index,Container item) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
ContainerBuilder builder = new ContainerBuilder(item);
if (index < 0 || index >= initContainers.size()) { _visitables.get("initContainers").add(builder); initContainers.add(builder); } else { _visitables.get("initContainers").set(index, builder); 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 (Container item : items) {ContainerBuilder builder = new ContainerBuilder(item);_visitables.get("initContainers").add(builder);this.initContainers.add(builder);} return (A)this;
}
public A addAllToInitContainers(Collection items) {
if (this.initContainers == null) {this.initContainers = new ArrayList();}
for (Container item : items) {ContainerBuilder builder = new ContainerBuilder(item);_visitables.get("initContainers").add(builder);this.initContainers.add(builder);} return (A)this;
}
public A removeFromInitContainers(io.dekorate.kubernetes.config.Container... items) {
if (this.initContainers == null) return (A)this;
for (Container item : items) {ContainerBuilder builder = new ContainerBuilder(item);_visitables.get("initContainers").remove(builder); this.initContainers.remove(builder);} return (A)this;
}
public A removeAllFromInitContainers(Collection items) {
if (this.initContainers == null) return (A)this;
for (Container item : items) {ContainerBuilder builder = new ContainerBuilder(item);_visitables.get("initContainers").remove(builder); this.initContainers.remove(builder);} return (A)this;
}
public A removeMatchingFromInitContainers(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.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public boolean hasInitContainers() {
return this.initContainers != null && !this.initContainers.isEmpty();
}
public InitContainersNested addNewInitContainer() {
return new InitContainersNested(-1, null);
}
public InitContainersNested addNewInitContainerLike(Container item) {
return new InitContainersNested(-1, item);
}
public InitContainersNested setNewInitContainerLike(int index,Container item) {
return new InitContainersNested(index, item);
}
public InitContainersNested editInitContainer(int index) {
if (initContainers.size() <= index) throw new RuntimeException("Can't edit initContainers. Index exceeds size.");
return setNewInitContainerLike(index, buildInitContainer(index));
}
public InitContainersNested editFirstInitContainer() {
if (initContainers.size() == 0) throw new RuntimeException("Can't edit first initContainers. The list is empty.");
return setNewInitContainerLike(0, buildInitContainer(0));
}
public InitContainersNested 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 InitContainersNested editMatchingInitContainer(Predicate predicate) {
int index = -1;
for (int i=0;i withNewRoute() {
return new RouteNested(null);
}
public RouteNested withNewRouteLike(Route item) {
return new RouteNested(item);
}
public RouteNested editRoute() {
return withNewRouteLike(java.util.Optional.ofNullable(buildRoute()).orElse(null));
}
public RouteNested editOrNewRoute() {
return withNewRouteLike(java.util.Optional.ofNullable(buildRoute()).orElse(new RouteBuilder().build()));
}
public RouteNested editOrNewRouteLike(Route item) {
return withNewRouteLike(java.util.Optional.ofNullable(buildRoute()).orElse(item));
}
public Boolean getHeadless() {
return this.headless;
}
public A withHeadless(Boolean headless) {
this.headless = headless;
return (A) this;
}
public boolean hasHeadless() {
return this.headless != null;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
OpenshiftConfigFluent that = (OpenshiftConfigFluent) o;
if (!java.util.Objects.equals(initContainers, that.initContainers)) return false;
if (!java.util.Objects.equals(replicas, that.replicas)) return false;
if (!java.util.Objects.equals(route, that.route)) return false;
if (!java.util.Objects.equals(headless, that.headless)) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(initContainers, replicas, route, headless, super.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (initContainers != null && !initContainers.isEmpty()) { sb.append("initContainers:"); sb.append(initContainers + ","); }
if (replicas != null) { sb.append("replicas:"); sb.append(replicas + ","); }
if (route != null) { sb.append("route:"); sb.append(route + ","); }
if (headless != null) { sb.append("headless:"); sb.append(headless); }
sb.append("}");
return sb.toString();
}
public A withHeadless() {
return withHeadless(true);
}
public class InitContainersNested extends ContainerFluent> implements Nested{
InitContainersNested(int index,Container item) {
this.index = index;
this.builder = new ContainerBuilder(this, item);
}
ContainerBuilder builder;
int index;
public N and() {
return (N) OpenshiftConfigFluent.this.setToInitContainers(index,builder.build());
}
public N endInitContainer() {
return and();
}
}
public class RouteNested extends RouteFluent> implements Nested{
RouteNested(Route item) {
this.builder = new RouteBuilder(this, item);
}
RouteBuilder builder;
public N and() {
return (N) OpenshiftConfigFluent.this.withRoute(builder.build());
}
public N endRoute() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy