All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dekorate.halkyon.config.CapabilityConfigFluentImpl Maven / Gradle / Ivy

There is a newer version: 2.0.0.beta2
Show newest version
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 CapabilityConfigFluentImpl> extends ConfigurationFluentImpl implements CapabilityConfigFluent {

    private String category;
    private String type;
    private String name;
    private String version = "";
    private List parameters =  new ArrayList();

    public CapabilityConfigFluentImpl() { 
    }


    public CapabilityConfigFluentImpl(CapabilityConfig instance) { 
        this.withProject(instance.getProject()); 
        this.withAttributes(instance.getAttributes()); 
        this.withCategory(instance.getCategory()); 
        this.withType(instance.getType()); 
        this.withName(instance.getName()); 
        this.withVersion(instance.getVersion()); 
        this.withParameters(instance.getParameters()); 
    }


    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 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 getVersion() {
        return this.version;
    }

    public A withVersion(String version) {
        this.version=version; return (A) this;
    }

    public Boolean hasVersion() {
        return this.version != null;
    }

    public A withNewVersion(String arg1) {
        return (A)withVersion(new String(arg1));
    }

    public A withNewVersion(StringBuilder arg1) {
        return (A)withVersion(new String(arg1));
    }

    public A withNewVersion(StringBuffer arg1) {
        return (A)withVersion(new String(arg1));
    }

    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 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 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 CapabilityConfigFluent.ParametersNested addNewParameter() {
        return new ParametersNestedImpl();
    }

    public CapabilityConfigFluent.ParametersNested addNewParameterLike(io.dekorate.halkyon.config.Parameter item) {
        return new ParametersNestedImpl(-1, item);
    }

    public CapabilityConfigFluent.ParametersNested setNewParameterLike(int index,io.dekorate.halkyon.config.Parameter item) {
        return new ParametersNestedImpl(index, item);
    }

    public CapabilityConfigFluent.ParametersNested editParameter(int index) {
        if (parameters.size() <= index) throw new RuntimeException("Can't edit parameters. Index exceeds size.");
        return setNewParameterLike(index, buildParameter(index));
    }

    public CapabilityConfigFluent.ParametersNested editFirstParameter() {
        if (parameters.size() == 0) throw new RuntimeException("Can't edit first parameters. The list is empty.");
        return setNewParameterLike(0, buildParameter(0));
    }

    public CapabilityConfigFluent.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 CapabilityConfigFluent.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 CapabilityConfigFluent.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) CapabilityConfigFluentImpl.this.setToParameters(index,builder.build());
        }

        public N endParameter() {
             return and();
        }
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy