io.dekorate.halkyon.model.ComponentCapabilityFluentImpl Maven / Gradle / Ivy
package io.dekorate.halkyon.model;
import io.dekorate.deps.kubernetes.api.builder.VisitableBuilder;
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.Deprecated;
import io.dekorate.deps.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.StringBuffer;
import java.util.Collection;
import java.lang.Object;
public class ComponentCapabilityFluentImpl> extends BaseFluent implements ComponentCapabilityFluent {
private String name;
private CapabilitySpecBuilder spec;
private List parameters;
public ComponentCapabilityFluentImpl() {
}
public ComponentCapabilityFluentImpl(ComponentCapability instance) {
this.withName(instance.getName());
this.withSpec(instance.getSpec());
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));
}
/**
* This method has been deprecated, please use method buildSpec instead.
* @return The buildable object.
*/
@Deprecated public CapabilitySpec getSpec() {
return this.spec!=null?this.spec.build():null;
}
public CapabilitySpec buildSpec() {
return this.spec!=null?this.spec.build():null;
}
public A withSpec(CapabilitySpec spec) {
_visitables.get("spec").remove(this.spec);
if (spec!=null){ this.spec= new CapabilitySpecBuilder(spec); _visitables.get("spec").add(this.spec);} return (A) this;
}
public Boolean hasSpec() {
return this.spec != null;
}
public ComponentCapabilityFluent.SpecNested withNewSpec() {
return new SpecNestedImpl();
}
public ComponentCapabilityFluent.SpecNested withNewSpecLike(CapabilitySpec item) {
return new SpecNestedImpl(item);
}
public ComponentCapabilityFluent.SpecNested editSpec() {
return withNewSpecLike(getSpec());
}
public ComponentCapabilityFluent.SpecNested editOrNewSpec() {
return withNewSpecLike(getSpec() != null ? getSpec(): new CapabilitySpecBuilder().build());
}
public ComponentCapabilityFluent.SpecNested editOrNewSpecLike(CapabilitySpec item) {
return withNewSpecLike(getSpec() != null ? getSpec(): item);
}
public A withParameters(io.dekorate.halkyon.model.Parameter... parameters) {
if (this.parameters != null) {this.parameters.clear();}
if (parameters != null) {for (io.dekorate.halkyon.model.Parameter item :parameters){ this.addToParameters(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildParameters instead.
*/
@Deprecated public io.dekorate.halkyon.model.Parameter[] getParameters() {
int size = parameters != null ? parameters.size() : 0;
io.dekorate.halkyon.model.Parameter[] result = new io.dekorate.halkyon.model.Parameter[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.halkyon.model.Parameter,?> builder : parameters) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.halkyon.model.Parameter[] buildParameters() {
int size = parameters != null ? parameters.size() : 0;
io.dekorate.halkyon.model.Parameter[] result = new io.dekorate.halkyon.model.Parameter[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends io.dekorate.halkyon.model.Parameter,?> builder : parameters) {
result[index++]=builder.build();
}
return result;
}
public io.dekorate.halkyon.model.Parameter buildParameter(int index) {
return this.parameters.get(index).build();
}
public io.dekorate.halkyon.model.Parameter buildFirstParameter() {
return this.parameters.get(0).build();
}
public io.dekorate.halkyon.model.Parameter buildLastParameter() {
return this.parameters.get(parameters.size() - 1).build();
}
public io.dekorate.halkyon.model.Parameter buildMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (ParameterBuilder item: parameters) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
for (ParameterBuilder item: parameters) { if(predicate.apply(item)){ return true;} } return false;
}
public A addToParameters(int index,io.dekorate.halkyon.model.Parameter item) {
if (this.parameters == null) {this.parameters = new ArrayList();}
io.dekorate.halkyon.model.ParameterBuilder builder = new io.dekorate.halkyon.model.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.model.Parameter item) {
if (this.parameters == null) {this.parameters = new ArrayList();}
io.dekorate.halkyon.model.ParameterBuilder builder = new io.dekorate.halkyon.model.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.model.Parameter... items) {
if (this.parameters == null) {this.parameters = new ArrayList();}
for (io.dekorate.halkyon.model.Parameter item : items) {io.dekorate.halkyon.model.ParameterBuilder builder = new io.dekorate.halkyon.model.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.model.Parameter item : items) {io.dekorate.halkyon.model.ParameterBuilder builder = new io.dekorate.halkyon.model.ParameterBuilder(item);_visitables.get("parameters").add(builder);this.parameters.add(builder);} return (A)this;
}
public A removeFromParameters(io.dekorate.halkyon.model.Parameter... items) {
for (io.dekorate.halkyon.model.Parameter item : items) {io.dekorate.halkyon.model.ParameterBuilder builder = new io.dekorate.halkyon.model.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.model.Parameter item : items) {io.dekorate.halkyon.model.ParameterBuilder builder = new io.dekorate.halkyon.model.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()) {
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 ComponentCapabilityFluent.ParametersNested addNewParameter() {
return new ParametersNestedImpl();
}
public ComponentCapabilityFluent.ParametersNested addNewParameterLike(io.dekorate.halkyon.model.Parameter item) {
return new ParametersNestedImpl(-1, item);
}
public ComponentCapabilityFluent.ParametersNested setNewParameterLike(int index,io.dekorate.halkyon.model.Parameter item) {
return new ParametersNestedImpl(index, item);
}
public ComponentCapabilityFluent.ParametersNested editParameter(int index) {
if (parameters.size() <= index) throw new RuntimeException("Can't edit parameters. Index exceeds size.");
return setNewParameterLike(index, buildParameter(index));
}
public ComponentCapabilityFluent.ParametersNested editFirstParameter() {
if (parameters.size() == 0) throw new RuntimeException("Can't edit first parameters. The list is empty.");
return setNewParameterLike(0, buildParameter(0));
}
public ComponentCapabilityFluent.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 ComponentCapabilityFluent.ParametersNested editMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate) {
int index = -1;
for (int i=0;i extends CapabilitySpecFluentImpl> implements ComponentCapabilityFluent.SpecNested,io.dekorate.deps.kubernetes.api.builder.Nested {
private final CapabilitySpecBuilder builder;
SpecNestedImpl(CapabilitySpec item) {
this.builder = new CapabilitySpecBuilder(this, item);
}
SpecNestedImpl() {
this.builder = new CapabilitySpecBuilder(this);
}
public N and() {
return (N) ComponentCapabilityFluentImpl.this.withSpec(builder.build());
}
public N endSpec() {
return and();
}
}
public class ParametersNestedImpl extends ParameterFluentImpl> implements ComponentCapabilityFluent.ParametersNested,io.dekorate.deps.kubernetes.api.builder.Nested {
private final ParameterBuilder builder;
private final int index;
ParametersNestedImpl(int index,io.dekorate.halkyon.model.Parameter item) {
this.index = index;
this.builder = new ParameterBuilder(this, item);
}
ParametersNestedImpl() {
this.index = -1;
this.builder = new ParameterBuilder(this);
}
public N and() {
return (N) ComponentCapabilityFluentImpl.this.setToParameters(index,builder.build());
}
public N endParameter() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy