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

io.dekorate.halkyon.model.CapabilitySpecFluentImpl Maven / Gradle / Ivy

There is a newer version: 2.0.0.beta2
Show newest version
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.StringBuffer;
import java.lang.Deprecated;
import io.dekorate.deps.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class CapabilitySpecFluentImpl> extends BaseFluent implements CapabilitySpecFluent{

    private String category;
    private String type;
    private String version;
    private List parameters;
    private String parametersJson;

    public CapabilitySpecFluentImpl(){
    }
    public CapabilitySpecFluentImpl(CapabilitySpec instance){
            this.withCategory(instance.getCategory()); 
            this.withType(instance.getType()); 
            this.withVersion(instance.getVersion()); 
            this.withParameters(instance.getParameters()); 
            this.withParametersJson(instance.getParametersJson()); 
    }

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

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

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

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

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

    public CapabilitySpecFluent.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 CapabilitySpecFluent.ParametersNested editMatchingParameter(io.dekorate.deps.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends ParameterFluentImpl> implements CapabilitySpecFluent.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) CapabilitySpecFluentImpl.this.setToParameters(index,builder.build());
    }
    public N endParameter(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy