io.dekorate.servicebinding.config.ServiceBindingConfigFluentImpl Maven / Gradle / Ivy
package io.dekorate.servicebinding.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 io.dekorate.kubernetes.config.Env;
import java.util.function.Predicate;
import java.lang.Deprecated;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.Integer;
import io.dekorate.kubernetes.config.EnvBuilder;
import io.dekorate.kubernetes.config.EnvFluentImpl;
import io.dekorate.kubernetes.config.ApplicationConfigurationFluentImpl;
import java.util.Collection;
import java.lang.Object;
/**
* Generated
*/
@SuppressWarnings(value = "unchecked")
public class ServiceBindingConfigFluentImpl> extends ApplicationConfigurationFluentImpl implements ServiceBindingConfigFluent{
public ServiceBindingConfigFluentImpl() {
}
public ServiceBindingConfigFluentImpl(ServiceBindingConfig instance) {
this.withProject(instance.getProject());
this.withAttributes(instance.getAttributes());
this.withPartOf(instance.getPartOf());
this.withName(instance.getName());
this.withVersion(instance.getVersion());
this.withApplication(instance.getApplication());
this.withServices(instance.getServices());
this.withEnvVarPrefix(instance.getEnvVarPrefix());
this.withDetectBindingResources(instance.getDetectBindingResources());
this.withBindAsFiles(instance.getBindAsFiles());
this.withMountPath(instance.getMountPath());
this.withCustomEnvVar(instance.getCustomEnvVar());
this.withBindingPath(instance.getBindingPath());
}
private ApplicationConfigBuilder application;
private ArrayList services = new ArrayList();
private String envVarPrefix;
private Boolean detectBindingResources;
private Boolean bindAsFiles;
private String mountPath;
private ArrayList customEnvVar = new ArrayList();
private BindingPathConfigBuilder bindingPath;
/**
* This method has been deprecated, please use method buildApplication instead.
* @return The buildable object.
*/
@Deprecated
public ApplicationConfig getApplication() {
return this.application!=null ?this.application.build():null;
}
public ApplicationConfig buildApplication() {
return this.application!=null ?this.application.build():null;
}
public A withApplication(ApplicationConfig application) {
_visitables.get("application").remove(this.application);
if (application!=null){ this.application= new ApplicationConfigBuilder(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 ServiceBindingConfigFluent.ApplicationNested withNewApplication() {
return new ServiceBindingConfigFluentImpl.ApplicationNestedImpl();
}
public ServiceBindingConfigFluent.ApplicationNested withNewApplicationLike(ApplicationConfig item) {
return new ServiceBindingConfigFluentImpl.ApplicationNestedImpl(item);
}
public ServiceBindingConfigFluent.ApplicationNested editApplication() {
return withNewApplicationLike(getApplication());
}
public ServiceBindingConfigFluent.ApplicationNested editOrNewApplication() {
return withNewApplicationLike(getApplication() != null ? getApplication(): new ApplicationConfigBuilder().build());
}
public ServiceBindingConfigFluent.ApplicationNested editOrNewApplicationLike(ApplicationConfig item) {
return withNewApplicationLike(getApplication() != null ? getApplication(): item);
}
public A withServices(io.dekorate.servicebinding.config.ServiceConfig... services) {
if (this.services != null) {this.services.clear();}
if (services != null) {for (ServiceConfig item :services){ this.addToServices(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildServices instead.
*/
@Deprecated
public ServiceConfig[] getServices() {
int size = services != null ? services.size() : 0;
ServiceConfig[] result = new ServiceConfig[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends ServiceConfig,?> builder : services) {
result[index++]=builder.build();
}
return result;
}
public ServiceConfig[] buildServices() {
int size = services != null ? services.size() : 0;
ServiceConfig[] result = new ServiceConfig[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends ServiceConfig,?> builder : services) {
result[index++]=builder.build();
}
return result;
}
public ServiceConfig buildService(Integer index) {
return this.services.get(index).build();
}
public ServiceConfig buildFirstService() {
return this.services.get(0).build();
}
public ServiceConfig buildLastService() {
return this.services.get(services.size() - 1).build();
}
public ServiceConfig buildMatchingService(Predicate predicate) {
for (ServiceConfigBuilder item: services) { if(predicate.test(item)){ return item.build();} } return null;
}
public Boolean hasMatchingService(Predicate predicate) {
for (ServiceConfigBuilder item: services) { if(predicate.test(item)){ return true;} } return false;
}
public A addToServices(Integer index,ServiceConfig item) {
if (this.services == null) {this.services = new ArrayList();}
ServiceConfigBuilder builder = new ServiceConfigBuilder(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,ServiceConfig item) {
if (this.services == null) {this.services = new ArrayList();}
ServiceConfigBuilder builder = new ServiceConfigBuilder(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.config.ServiceConfig... items) {
if (this.services == null) {this.services = new ArrayList();}
for (ServiceConfig item : items) {ServiceConfigBuilder builder = new ServiceConfigBuilder(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 (ServiceConfig item : items) {ServiceConfigBuilder builder = new ServiceConfigBuilder(item);_visitables.get("services").add(builder);this.services.add(builder);} return (A)this;
}
public A removeFromServices(io.dekorate.servicebinding.config.ServiceConfig... items) {
for (ServiceConfig item : items) {ServiceConfigBuilder builder = new ServiceConfigBuilder(item);_visitables.get("services").remove(builder);if (this.services != null) {this.services.remove(builder);}} return (A)this;
}
public A removeAllFromServices(Collection items) {
for (ServiceConfig item : items) {ServiceConfigBuilder builder = new ServiceConfigBuilder(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()) {
ServiceConfigBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasServices() {
return services != null && !services.isEmpty();
}
public ServiceBindingConfigFluent.ServicesNested addNewService() {
return new ServiceBindingConfigFluentImpl.ServicesNestedImpl();
}
public ServiceBindingConfigFluent.ServicesNested addNewServiceLike(ServiceConfig item) {
return new ServiceBindingConfigFluentImpl.ServicesNestedImpl(-1, item);
}
public ServiceBindingConfigFluent.ServicesNested setNewServiceLike(Integer index,ServiceConfig item) {
return new ServiceBindingConfigFluentImpl.ServicesNestedImpl(index, item);
}
public ServiceBindingConfigFluent.ServicesNested editService(Integer index) {
if (services.size() <= index) throw new RuntimeException("Can't edit services. Index exceeds size.");
return setNewServiceLike(index, buildService(index));
}
public ServiceBindingConfigFluent.ServicesNested editFirstService() {
if (services.size() == 0) throw new RuntimeException("Can't edit first services. The list is empty.");
return setNewServiceLike(0, buildService(0));
}
public ServiceBindingConfigFluent.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 ServiceBindingConfigFluent.ServicesNested editMatchingService(Predicate predicate) {
int index = -1;
for (int i=0;i builder : customEnvVar) {
result[index++]=builder.build();
}
return result;
}
public Env[] buildCustomEnvVar() {
int size = customEnvVar != null ? customEnvVar.size() : 0;
Env[] result = new Env[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends Env,?> builder : customEnvVar) {
result[index++]=builder.build();
}
return result;
}
public Env buildCustomEnvVar(Integer index) {
return this.customEnvVar.get(index).build();
}
public Env buildFirstCustomEnvVar() {
return this.customEnvVar.get(0).build();
}
public Env buildLastCustomEnvVar() {
return this.customEnvVar.get(customEnvVar.size() - 1).build();
}
public Env buildMatchingCustomEnvVar(Predicate predicate) {
for (EnvBuilder item: customEnvVar) { if(predicate.test(item)){ return item.build();} } return null;
}
public Boolean hasMatchingCustomEnvVar(Predicate predicate) {
for (EnvBuilder item: customEnvVar) { if(predicate.test(item)){ return true;} } return false;
}
public A addToCustomEnvVar(Integer index,Env item) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
EnvBuilder builder = new EnvBuilder(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,Env item) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
EnvBuilder builder = new EnvBuilder(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.kubernetes.config.Env... items) {
if (this.customEnvVar == null) {this.customEnvVar = new ArrayList();}
for (Env item : items) {EnvBuilder builder = new EnvBuilder(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 (Env item : items) {EnvBuilder builder = new EnvBuilder(item);_visitables.get("customEnvVar").add(builder);this.customEnvVar.add(builder);} return (A)this;
}
public A removeFromCustomEnvVar(io.dekorate.kubernetes.config.Env... items) {
for (Env item : items) {EnvBuilder builder = new EnvBuilder(item);_visitables.get("customEnvVar").remove(builder);if (this.customEnvVar != null) {this.customEnvVar.remove(builder);}} return (A)this;
}
public A removeAllFromCustomEnvVar(Collection items) {
for (Env item : items) {EnvBuilder builder = new EnvBuilder(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()) {
EnvBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasCustomEnvVar() {
return customEnvVar != null && !customEnvVar.isEmpty();
}
public ServiceBindingConfigFluent.CustomEnvVarNested addNewCustomEnvVar() {
return new ServiceBindingConfigFluentImpl.CustomEnvVarNestedImpl();
}
public ServiceBindingConfigFluent.CustomEnvVarNested addNewCustomEnvVarLike(Env item) {
return new ServiceBindingConfigFluentImpl.CustomEnvVarNestedImpl(-1, item);
}
public ServiceBindingConfigFluent.CustomEnvVarNested setNewCustomEnvVarLike(Integer index,Env item) {
return new ServiceBindingConfigFluentImpl.CustomEnvVarNestedImpl(index, item);
}
public ServiceBindingConfigFluent.CustomEnvVarNested editCustomEnvVar(Integer index) {
if (customEnvVar.size() <= index) throw new RuntimeException("Can't edit customEnvVar. Index exceeds size.");
return setNewCustomEnvVarLike(index, buildCustomEnvVar(index));
}
public ServiceBindingConfigFluent.CustomEnvVarNested editFirstCustomEnvVar() {
if (customEnvVar.size() == 0) throw new RuntimeException("Can't edit first customEnvVar. The list is empty.");
return setNewCustomEnvVarLike(0, buildCustomEnvVar(0));
}
public ServiceBindingConfigFluent.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 ServiceBindingConfigFluent.CustomEnvVarNested editMatchingCustomEnvVar(Predicate predicate) {
int index = -1;
for (int i=0;i withNewBindingPath() {
return new ServiceBindingConfigFluentImpl.BindingPathNestedImpl();
}
public ServiceBindingConfigFluent.BindingPathNested withNewBindingPathLike(BindingPathConfig item) {
return new ServiceBindingConfigFluentImpl.BindingPathNestedImpl(item);
}
public ServiceBindingConfigFluent.BindingPathNested editBindingPath() {
return withNewBindingPathLike(getBindingPath());
}
public ServiceBindingConfigFluent.BindingPathNested editOrNewBindingPath() {
return withNewBindingPathLike(getBindingPath() != null ? getBindingPath(): new BindingPathConfigBuilder().build());
}
public ServiceBindingConfigFluent.BindingPathNested editOrNewBindingPathLike(BindingPathConfig item) {
return withNewBindingPathLike(getBindingPath() != null ? getBindingPath(): item);
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
ServiceBindingConfigFluentImpl that = (ServiceBindingConfigFluentImpl) o;
if (application != null ? !application.equals(that.application) :that.application != null) return false;
if (services != null ? !services.equals(that.services) :that.services != null) return false;
if (envVarPrefix != null ? !envVarPrefix.equals(that.envVarPrefix) :that.envVarPrefix != null) return false;
if (detectBindingResources != null ? !detectBindingResources.equals(that.detectBindingResources) :that.detectBindingResources != null) return false;
if (bindAsFiles != null ? !bindAsFiles.equals(that.bindAsFiles) :that.bindAsFiles != null) return false;
if (mountPath != null ? !mountPath.equals(that.mountPath) :that.mountPath != null) return false;
if (customEnvVar != null ? !customEnvVar.equals(that.customEnvVar) :that.customEnvVar != null) return false;
if (bindingPath != null ? !bindingPath.equals(that.bindingPath) :that.bindingPath != null) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(application, services, envVarPrefix, detectBindingResources, bindAsFiles, mountPath, customEnvVar, bindingPath, super.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (application != null) { sb.append("application:"); sb.append(application + ","); }
if (services != null && !services.isEmpty()) { sb.append("services:"); sb.append(services + ","); }
if (envVarPrefix != null) { sb.append("envVarPrefix:"); sb.append(envVarPrefix + ","); }
if (detectBindingResources != null) { sb.append("detectBindingResources:"); sb.append(detectBindingResources + ","); }
if (bindAsFiles != null) { sb.append("bindAsFiles:"); sb.append(bindAsFiles + ","); }
if (mountPath != null) { sb.append("mountPath:"); sb.append(mountPath + ","); }
if (customEnvVar != null && !customEnvVar.isEmpty()) { sb.append("customEnvVar:"); sb.append(customEnvVar + ","); }
if (bindingPath != null) { sb.append("bindingPath:"); sb.append(bindingPath); }
sb.append("}");
return sb.toString();
}
public A withDetectBindingResources() {
return withDetectBindingResources(true);
}
public A withBindAsFiles() {
return withBindAsFiles(true);
}
class ApplicationNestedImpl extends ApplicationConfigFluentImpl> implements ServiceBindingConfigFluent.ApplicationNested,Nested{
ApplicationNestedImpl(ApplicationConfig item) {
this.builder = new ApplicationConfigBuilder(this, item);
}
ApplicationNestedImpl() {
this.builder = new ApplicationConfigBuilder(this);
}
ApplicationConfigBuilder builder;
public N and() {
return (N) ServiceBindingConfigFluentImpl.this.withApplication(builder.build());
}
public N endApplication() {
return and();
}
}
class ServicesNestedImpl extends ServiceConfigFluentImpl> implements ServiceBindingConfigFluent.ServicesNested,Nested{
ServicesNestedImpl(Integer index,ServiceConfig item) {
this.index = index;
this.builder = new ServiceConfigBuilder(this, item);
}
ServicesNestedImpl() {
this.index = -1;
this.builder = new ServiceConfigBuilder(this);
}
ServiceConfigBuilder builder;
Integer index;
public N and() {
return (N) ServiceBindingConfigFluentImpl.this.setToServices(index,builder.build());
}
public N endService() {
return and();
}
}
class CustomEnvVarNestedImpl extends EnvFluentImpl> implements ServiceBindingConfigFluent.CustomEnvVarNested,Nested{
CustomEnvVarNestedImpl(Integer index,Env item) {
this.index = index;
this.builder = new EnvBuilder(this, item);
}
CustomEnvVarNestedImpl() {
this.index = -1;
this.builder = new EnvBuilder(this);
}
EnvBuilder builder;
Integer index;
public N and() {
return (N) ServiceBindingConfigFluentImpl.this.setToCustomEnvVar(index,builder.build());
}
public N endCustomEnvVar() {
return and();
}
}
class BindingPathNestedImpl extends BindingPathConfigFluentImpl> implements ServiceBindingConfigFluent.BindingPathNested,Nested{
BindingPathNestedImpl(BindingPathConfig item) {
this.builder = new BindingPathConfigBuilder(this, item);
}
BindingPathNestedImpl() {
this.builder = new BindingPathConfigBuilder(this);
}
BindingPathConfigBuilder builder;
public N and() {
return (N) ServiceBindingConfigFluentImpl.this.withBindingPath(builder.build());
}
public N endBindingPath() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy