io.dekorate.halkyon.config.RequiredCapabilityConfigFluentImpl Maven / Gradle / Ivy
package io.dekorate.halkyon.config;
import io.dekorate.deps.kubernetes.api.builder.VisitableBuilder;
import io.dekorate.kubernetes.config.ConfigurationFluentImpl;
import java.lang.StringBuilder;
import io.dekorate.deps.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.dekorate.deps.kubernetes.api.builder.Predicate;
import java.lang.StringBuffer;
import java.lang.Deprecated;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class RequiredCapabilityConfigFluentImpl> extends ConfigurationFluentImpl implements RequiredCapabilityConfigFluent {
private String name = "";
private String category = "";
private String type = "";
private String boundTo = "";
private boolean autoBindable = false;
private List parameters = new ArrayList();
public RequiredCapabilityConfigFluentImpl() {
}
public RequiredCapabilityConfigFluentImpl(RequiredCapabilityConfig instance) {
this.withProject(instance.getProject());
this.withAttributes(instance.getAttributes());
this.withName(instance.getName());
this.withCategory(instance.getCategory());
this.withType(instance.getType());
this.withBoundTo(instance.getBoundTo());
this.withAutoBindable(instance.isAutoBindable());
this.withParameters(instance.getParameters());
}
public String getName() {
return this.name;
}
public A withName(String name) {
this.name=name; return (A) this;
}
public Boolean hasName() {
return this.name != null;
}
public A withNewName(String arg1) {
return (A)withName(new String(arg1));
}
public A withNewName(StringBuilder arg1) {
return (A)withName(new String(arg1));
}
public A withNewName(StringBuffer arg1) {
return (A)withName(new String(arg1));
}
public String getCategory() {
return this.category;
}
public A withCategory(String category) {
this.category=category; return (A) this;
}
public Boolean hasCategory() {
return this.category != null;
}
public A withNewCategory(String arg1) {
return (A)withCategory(new String(arg1));
}
public A withNewCategory(StringBuilder arg1) {
return (A)withCategory(new String(arg1));
}
public A withNewCategory(StringBuffer arg1) {
return (A)withCategory(new String(arg1));
}
public String getType() {
return this.type;
}
public A withType(String type) {
this.type=type; return (A) this;
}
public Boolean hasType() {
return this.type != null;
}
public A withNewType(String arg1) {
return (A)withType(new String(arg1));
}
public A withNewType(StringBuilder arg1) {
return (A)withType(new String(arg1));
}
public A withNewType(StringBuffer arg1) {
return (A)withType(new String(arg1));
}
public String getBoundTo() {
return this.boundTo;
}
public A withBoundTo(String boundTo) {
this.boundTo=boundTo; return (A) this;
}
public Boolean hasBoundTo() {
return this.boundTo != null;
}
public A withNewBoundTo(String arg1) {
return (A)withBoundTo(new String(arg1));
}
public A withNewBoundTo(StringBuilder arg1) {
return (A)withBoundTo(new String(arg1));
}
public A withNewBoundTo(StringBuffer arg1) {
return (A)withBoundTo(new String(arg1));
}
public boolean isAutoBindable() {
return this.autoBindable;
}
public A withAutoBindable(boolean autoBindable) {
this.autoBindable=autoBindable; return (A) this;
}
public Boolean hasAutoBindable() {
return true;
}
public A withParameters(io.dekorate.halkyon.config.Parameter... parameters) {
if (this.parameters != null) {this.parameters.clear();}
if (parameters != null) {for (io.dekorate.halkyon.config.Parameter item :parameters){ this.addToParameters(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildParameters instead.
*/
@Deprecated public io.dekorate.halkyon.config.Parameter[] getParameters() {
int size = parameters != null ? parameters.size() : 0;
io.dekorate.halkyon.config.Parameter[] result = new io.dekorate.halkyon.config.Parameter[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.halkyon.config.Parameter,?> builder : parameters) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.halkyon.config.Parameter[] buildParameters() {
int size = parameters != null ? parameters.size() : 0;
io.dekorate.halkyon.config.Parameter[] result = new io.dekorate.halkyon.config.Parameter[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.halkyon.config.Parameter,?> builder : parameters) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.halkyon.config.Parameter buildParameter(int index) {
return this.parameters.get(index).build();
}
public io.dekorate.halkyon.config.Parameter buildFirstParameter() {
return this.parameters.get(0).build();
}
public io.dekorate.halkyon.config.Parameter buildLastParameter() {
return this.parameters.get(parameters.size() - 1).build();
}
public io.dekorate.halkyon.config.Parameter buildMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (io.dekorate.halkyon.config.ParameterBuilder item: parameters) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (io.dekorate.halkyon.config.ParameterBuilder item: parameters) { if(predicate.apply(item)){ return true;} } return false;
}
public A addToParameters(int index,io.dekorate.halkyon.config.Parameter item) {
if (this.parameters == null) {this.parameters = new ArrayList();}
io.dekorate.halkyon.config.ParameterBuilder builder = new io.dekorate.halkyon.config.ParameterBuilder(item);_visitables.get("parameters").add(index >= 0 ? index : _visitables.get("parameters").size(), builder);this.parameters.add(index >= 0 ? index : parameters.size(), builder); return (A)this;
}
public A setToParameters(int index,io.dekorate.halkyon.config.Parameter item) {
if (this.parameters == null) {this.parameters = new ArrayList();}
io.dekorate.halkyon.config.ParameterBuilder builder = new io.dekorate.halkyon.config.ParameterBuilder(item);
if (index < 0 || index >= _visitables.get("parameters").size()) { _visitables.get("parameters").add(builder); } else { _visitables.get("parameters").set(index, builder);}
if (index < 0 || index >= parameters.size()) { parameters.add(builder); } else { parameters.set(index, builder);}
return (A)this;
}
public A addToParameters(io.dekorate.halkyon.config.Parameter... items) {
if (this.parameters == null) {this.parameters = new ArrayList();}
for (io.dekorate.halkyon.config.Parameter item : items) {io.dekorate.halkyon.config.ParameterBuilder builder = new io.dekorate.halkyon.config.ParameterBuilder(item);_visitables.get("parameters").add(builder);this.parameters.add(builder);} return (A)this;
}
public A addAllToParameters(Collection items) {
if (this.parameters == null) {this.parameters = new ArrayList();}
for (io.dekorate.halkyon.config.Parameter item : items) {io.dekorate.halkyon.config.ParameterBuilder builder = new io.dekorate.halkyon.config.ParameterBuilder(item);_visitables.get("parameters").add(builder);this.parameters.add(builder);} return (A)this;
}
public A removeFromParameters(io.dekorate.halkyon.config.Parameter... items) {
for (io.dekorate.halkyon.config.Parameter item : items) {io.dekorate.halkyon.config.ParameterBuilder builder = new io.dekorate.halkyon.config.ParameterBuilder(item);_visitables.get("parameters").remove(builder);if (this.parameters != null) {this.parameters.remove(builder);}} return (A)this;
}
public A removeAllFromParameters(Collection items) {
for (io.dekorate.halkyon.config.Parameter item : items) {io.dekorate.halkyon.config.ParameterBuilder builder = new io.dekorate.halkyon.config.ParameterBuilder(item);_visitables.get("parameters").remove(builder);if (this.parameters != null) {this.parameters.remove(builder);}} return (A)this;
}
public A removeMatchingFromParameters(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
if (parameters == null) return (A) this;
final Iterator each = parameters.iterator();
final List visitables = _visitables.get("parameters");
while (each.hasNext()) {
io.dekorate.halkyon.config.ParameterBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasParameters() {
return parameters != null && !parameters.isEmpty();
}
public A addNewParameter(String name,String value) {
return (A)addToParameters(new Parameter(name, value));
}
public RequiredCapabilityConfigFluent.ParametersNested addNewParameter() {
return new ParametersNestedImpl();
}
public RequiredCapabilityConfigFluent.ParametersNested addNewParameterLike(io.dekorate.halkyon.config.Parameter item) {
return new ParametersNestedImpl(-1, item);
}
public RequiredCapabilityConfigFluent.ParametersNested setNewParameterLike(int index,io.dekorate.halkyon.config.Parameter item) {
return new ParametersNestedImpl(index, item);
}
public RequiredCapabilityConfigFluent.ParametersNested editParameter(int index) {
if (parameters.size() <= index) throw new RuntimeException("Can't edit parameters. Index exceeds size.");
return setNewParameterLike(index, buildParameter(index));
}
public RequiredCapabilityConfigFluent.ParametersNested editFirstParameter() {
if (parameters.size() == 0) throw new RuntimeException("Can't edit first parameters. The list is empty.");
return setNewParameterLike(0, buildParameter(0));
}
public RequiredCapabilityConfigFluent.ParametersNested editLastParameter() {
int index = parameters.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last parameters. The list is empty.");
return setNewParameterLike(index, buildParameter(index));
}
public RequiredCapabilityConfigFluent.ParametersNested editMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
int index = -1;
for (int i=0;i extends io.dekorate.halkyon.config.ParameterFluentImpl> implements RequiredCapabilityConfigFluent.ParametersNested,io.dekorate.deps.kubernetes.api.builder.Nested {
private final io.dekorate.halkyon.config.ParameterBuilder builder;
private final int index;
ParametersNestedImpl(int index,io.dekorate.halkyon.config.Parameter item) {
this.index = index;
this.builder = new io.dekorate.halkyon.config.ParameterBuilder(this, item);
}
ParametersNestedImpl() {
this.index = -1;
this.builder = new io.dekorate.halkyon.config.ParameterBuilder(this);
}
public N and() {
return (N) RequiredCapabilityConfigFluentImpl.this.setToParameters(index,builder.build());
}
public N endParameter() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy