io.dekorate.servicebinding.model.ServiceBindingSpecFluentImpl Maven / Gradle / Ivy
package io.dekorate.servicebinding.model;
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 java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.Integer;
import java.util.Collection;
import java.lang.Object;
/**
* Generated
*/
@SuppressWarnings(value = "unchecked")
public class ServiceBindingSpecFluentImpl> extends BaseFluent implements ServiceBindingSpecFluent{
public ServiceBindingSpecFluentImpl() {
}
public ServiceBindingSpecFluentImpl(ServiceBindingSpec instance) {
this.withApplication(instance.getApplication());
this.withServices(instance.getServices());
this.withEnvVarPrefix(instance.getEnvVarPrefix());
this.withDetectBindingResources(instance.getDetectBindingResources());
this.withBindAsFiles(instance.isBindAsFiles());
this.withMountPath(instance.getMountPath());
this.withCustomEnvVar(instance.getCustomEnvVar());
}
private ApplicationBuilder application;
private ArrayList services;
private String envVarPrefix;
private boolean detectBindingResources;
private boolean bindAsFiles;
private String mountPath;
private ArrayList customEnvVar;
/**
* This method has been deprecated, please use method buildApplication instead.
* @return The buildable object.
*/
@Deprecated
public Application getApplication() {
return this.application!=null ?this.application.build():null;
}
public Application buildApplication() {
return this.application!=null ?this.application.build():null;
}
public A withApplication(Application application) {
_visitables.get("application").remove(this.application);
if (application!=null){ this.application= new ApplicationBuilder(application); _visitables.get("application").add(this.application);} else { this.application = null; _visitables.get("application").remove(this.application); } return (A) this;
}
public Boolean hasApplication() {
return this.application != null;
}
public ServiceBindingSpecFluent.ApplicationNested withNewApplication() {
return new ServiceBindingSpecFluentImpl.ApplicationNestedImpl();
}
public ServiceBindingSpecFluent.ApplicationNested withNewApplicationLike(Application item) {
return new ServiceBindingSpecFluentImpl.ApplicationNestedImpl(item);
}
public ServiceBindingSpecFluent.ApplicationNested editApplication() {
return withNewApplicationLike(getApplication());
}
public ServiceBindingSpecFluent.ApplicationNested editOrNewApplication() {
return withNewApplicationLike(getApplication() != null ? getApplication(): new ApplicationBuilder().build());
}
public ServiceBindingSpecFluent.ApplicationNested editOrNewApplicationLike(Application item) {
return withNewApplicationLike(getApplication() != null ? getApplication(): item);
}
public A withServices(io.dekorate.servicebinding.model.Service... services) {
if (this.services != null) {this.services.clear();}
if (services != null) {for (Service item :services){ this.addToServices(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildServices instead.
*/
@Deprecated
public Service[] getServices() {
int size = services != null ? services.size() : 0;
Service[] result = new Service[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends Service,?> builder : services) {
result[index++]=builder.build();
}
return result;
}
public Service[] buildServices() {
int size = services != null ? services.size() : 0;
Service[] result = new Service[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends Service,?> builder : services) {
result[index++]=builder.build();
}
return result;
}
public Service buildService(Integer index) {
return this.services.get(index).build();
}
public Service buildFirstService() {
return this.services.get(0).build();
}
public Service buildLastService() {
return this.services.get(services.size() - 1).build();
}
public Service buildMatchingService(Predicate predicate) {
for (ServiceBuilder item: services) { if(predicate.test(item)){ return item.build();} } return null;
}
public Boolean hasMatchingService(Predicate predicate) {
for (ServiceBuilder item: services) { if(predicate.test(item)){ return true;} } return false;
}
public A addToServices(Integer index,Service item) {
if (this.services == null) {this.services = new ArrayList();}
ServiceBuilder builder = new ServiceBuilder(item);_visitables.get("services").add(index >= 0 ? index : _visitables.get("services").size(), builder);this.services.add(index >= 0 ? index : services.size(), builder); return (A)this;
}
public A setToServices(Integer index,Service item) {
if (this.services == null) {this.services = new ArrayList();}
ServiceBuilder builder = new ServiceBuilder(item);
if (index < 0 || index >= _visitables.get("services").size()) { _visitables.get("services").add(builder); } else { _visitables.get("services").set(index, builder);}
if (index < 0 || index >= services.size()) { services.add(builder); } else { services.set(index, builder);}
return (A)this;
}
public A addToServices(io.dekorate.servicebinding.model.Service... items) {
if (this.services == null) {this.services = new ArrayList();}
for (Service item : items) {ServiceBuilder builder = new ServiceBuilder(item);_visitables.get("services").add(builder);this.services.add(builder);} return (A)this;
}
public A addAllToServices(Collection items) {
if (this.services == null) {this.services = new ArrayList();}
for (Service item : items) {ServiceBuilder builder = new ServiceBuilder(item);_visitables.get("services").add(builder);this.services.add(builder);} return (A)this;
}
public A removeFromServices(io.dekorate.servicebinding.model.Service... items) {
for (Service item : items) {ServiceBuilder builder = new ServiceBuilder(item);_visitables.get("services").remove(builder);if (this.services != null) {this.services.remove(builder);}} return (A)this;
}
public A removeAllFromServices(Collection items) {
for (Service item : items) {ServiceBuilder builder = new ServiceBuilder(item);_visitables.get("services").remove(builder);if (this.services != null) {this.services.remove(builder);}} return (A)this;
}
public A removeMatchingFromServices(Predicate predicate) {
if (services == null) return (A) this;
final Iterator each = services.iterator();
final List visitables = _visitables.get("services");
while (each.hasNext()) {
ServiceBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasServices() {
return services != null && !services.isEmpty();
}
public ServiceBindingSpecFluent.ServicesNested addNewService() {
return new ServiceBindingSpecFluentImpl.ServicesNestedImpl();
}
public ServiceBindingSpecFluent.ServicesNested addNewServiceLike(Service item) {
return new ServiceBindingSpecFluentImpl.ServicesNestedImpl(-1, item);
}
public ServiceBindingSpecFluent.ServicesNested setNewServiceLike(Integer index,Service item) {
return new ServiceBindingSpecFluentImpl.ServicesNestedImpl(index, item);
}
public ServiceBindingSpecFluent.ServicesNested editService(Integer index) {
if (services.size() <= index) throw new RuntimeException("Can't edit services. Index exceeds size.");
return setNewServiceLike(index, buildService(index));
}
public ServiceBindingSpecFluent.ServicesNested editFirstService() {
if (services.size() == 0) throw new RuntimeException("Can't edit first services. The list is empty.");
return setNewServiceLike(0, buildService(0));
}
public ServiceBindingSpecFluent.ServicesNested editLastService() {
int index = services.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last services. The list is empty.");
return setNewServiceLike(index, buildService(index));
}
public ServiceBindingSpecFluent.ServicesNested editMatchingService(Predicate predicate) {
int index = -1;
for (int i=0;i builder : customEnvVar) {
result[index++]=builder.build();
}
return result;
}
public CustomEnvVar[] buildCustomEnvVar() {
int size = customEnvVar != null ? customEnvVar.size() : 0;
CustomEnvVar[] result = new CustomEnvVar[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends CustomEnvVar,?> builder : customEnvVar) {
result[index++]=builder.build();
}
return result;
}
public CustomEnvVar buildCustomEnvVar(Integer index) {
return this.customEnvVar.get(index).build();
}
public CustomEnvVar buildFirstCustomEnvVar() {
return this.customEnvVar.get(0).build();
}
public CustomEnvVar buildLastCustomEnvVar() {
return this.customEnvVar.get(customEnvVar.size() - 1).build();
}
public CustomEnvVar buildMatchingCustomEnvVar(Predicate predicate) {
for (CustomEnvVarBuilder item: customEnvVar) { if(predicate.test(item)){ return item.build();} } return null;
}
public Boolean hasMatchingCustomEnvVar(Predicate predicate) {
for (CustomEnvVarBuilder item: customEnvVar) { if(predicate.test(item)){ return true;} } return false;
}
public A addToCustomEnvVar(Integer index,CustomEnvVar item) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
CustomEnvVarBuilder builder = new CustomEnvVarBuilder(item);_visitables.get("customEnvVar").add(index >= 0 ? index : _visitables.get("customEnvVar").size(), builder);this.customEnvVar.add(index >= 0 ? index : customEnvVar.size(), builder); return (A)this;
}
public A setToCustomEnvVar(Integer index,CustomEnvVar item) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
CustomEnvVarBuilder builder = new CustomEnvVarBuilder(item);
if (index < 0 || index >= _visitables.get("customEnvVar").size()) { _visitables.get("customEnvVar").add(builder); } else { _visitables.get("customEnvVar").set(index, builder);}
if (index < 0 || index >= customEnvVar.size()) { customEnvVar.add(builder); } else { customEnvVar.set(index, builder);}
return (A)this;
}
public A addToCustomEnvVar(io.dekorate.servicebinding.model.CustomEnvVar... items) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
for (CustomEnvVar item : items) {CustomEnvVarBuilder builder = new CustomEnvVarBuilder(item);_visitables.get("customEnvVar").add(builder);this.customEnvVar.add(builder);} return (A)this;
}
public A addAllToCustomEnvVar(Collection items) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
for (CustomEnvVar item : items) {CustomEnvVarBuilder builder = new CustomEnvVarBuilder(item);_visitables.get("customEnvVar").add(builder);this.customEnvVar.add(builder);} return (A)this;
}
public A removeFromCustomEnvVar(io.dekorate.servicebinding.model.CustomEnvVar... items) {
for (CustomEnvVar item : items) {CustomEnvVarBuilder builder = new CustomEnvVarBuilder(item);_visitables.get("customEnvVar").remove(builder);if (this.customEnvVar != null) {this.customEnvVar.remove(builder);}} return (A)this;
}
public A removeAllFromCustomEnvVar(Collection items) {
for (CustomEnvVar item : items) {CustomEnvVarBuilder builder = new CustomEnvVarBuilder(item);_visitables.get("customEnvVar").remove(builder);if (this.customEnvVar != null) {this.customEnvVar.remove(builder);}} return (A)this;
}
public A removeMatchingFromCustomEnvVar(Predicate predicate) {
if (customEnvVar == null) return (A) this;
final Iterator each = customEnvVar.iterator();
final List visitables = _visitables.get("customEnvVar");
while (each.hasNext()) {
CustomEnvVarBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasCustomEnvVar() {
return customEnvVar != null && !customEnvVar.isEmpty();
}
public ServiceBindingSpecFluent.CustomEnvVarNested addNewCustomEnvVar() {
return new ServiceBindingSpecFluentImpl.CustomEnvVarNestedImpl();
}
public ServiceBindingSpecFluent.CustomEnvVarNested addNewCustomEnvVarLike(CustomEnvVar item) {
return new ServiceBindingSpecFluentImpl.CustomEnvVarNestedImpl(-1, item);
}
public ServiceBindingSpecFluent.CustomEnvVarNested setNewCustomEnvVarLike(Integer index,CustomEnvVar item) {
return new ServiceBindingSpecFluentImpl.CustomEnvVarNestedImpl(index, item);
}
public ServiceBindingSpecFluent.CustomEnvVarNested editCustomEnvVar(Integer index) {
if (customEnvVar.size() <= index) throw new RuntimeException("Can't edit customEnvVar. Index exceeds size.");
return setNewCustomEnvVarLike(index, buildCustomEnvVar(index));
}
public ServiceBindingSpecFluent.CustomEnvVarNested editFirstCustomEnvVar() {
if (customEnvVar.size() == 0) throw new RuntimeException("Can't edit first customEnvVar. The list is empty.");
return setNewCustomEnvVarLike(0, buildCustomEnvVar(0));
}
public ServiceBindingSpecFluent.CustomEnvVarNested editLastCustomEnvVar() {
int index = customEnvVar.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last customEnvVar. The list is empty.");
return setNewCustomEnvVarLike(index, buildCustomEnvVar(index));
}
public ServiceBindingSpecFluent.CustomEnvVarNested editMatchingCustomEnvVar(Predicate predicate) {
int index = -1;
for (int i=0;i extends ApplicationFluentImpl> implements ServiceBindingSpecFluent.ApplicationNested,Nested{
ApplicationNestedImpl(Application item) {
this.builder = new ApplicationBuilder(this, item);
}
ApplicationNestedImpl() {
this.builder = new ApplicationBuilder(this);
}
ApplicationBuilder builder;
public N and() {
return (N) ServiceBindingSpecFluentImpl.this.withApplication(builder.build());
}
public N endApplication() {
return and();
}
}
class ServicesNestedImpl extends ServiceFluentImpl> implements ServiceBindingSpecFluent.ServicesNested,Nested{
ServicesNestedImpl(Integer index,Service item) {
this.index = index;
this.builder = new ServiceBuilder(this, item);
}
ServicesNestedImpl() {
this.index = -1;
this.builder = new ServiceBuilder(this);
}
ServiceBuilder builder;
Integer index;
public N and() {
return (N) ServiceBindingSpecFluentImpl.this.setToServices(index,builder.build());
}
public N endService() {
return and();
}
}
class CustomEnvVarNestedImpl extends CustomEnvVarFluentImpl> implements ServiceBindingSpecFluent.CustomEnvVarNested,Nested{
CustomEnvVarNestedImpl(Integer index,CustomEnvVar item) {
this.index = index;
this.builder = new CustomEnvVarBuilder(this, item);
}
CustomEnvVarNestedImpl() {
this.index = -1;
this.builder = new CustomEnvVarBuilder(this);
}
CustomEnvVarBuilder builder;
Integer index;
public N and() {
return (N) ServiceBindingSpecFluentImpl.this.setToCustomEnvVar(index,builder.build());
}
public N endCustomEnvVar() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy