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

io.alauda.kubernetes.api.model.NodeSelectorFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.2.12
Show newest version
package io.alauda.kubernetes.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class NodeSelectorFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements NodeSelectorFluent{

    private List nodeSelectorTerms =  new ArrayList();

    public NodeSelectorFluentImpl(){
    }
    public NodeSelectorFluentImpl(NodeSelector instance){
            this.withNodeSelectorTerms(instance.getNodeSelectorTerms()); 
    }

    public A addToNodeSelectorTerms(int index,NodeSelectorTerm item){
            NodeSelectorTermBuilder builder = new NodeSelectorTermBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.nodeSelectorTerms.add(index >= 0 ? index : nodeSelectorTerms.size(), builder); return (A)this;
    }

    public A setToNodeSelectorTerms(int index,NodeSelectorTerm item){
            NodeSelectorTermBuilder builder = new NodeSelectorTermBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= nodeSelectorTerms.size()) { nodeSelectorTerms.add(builder); } else { nodeSelectorTerms.set(index, builder);}
             return (A)this;
    }

    public A addToNodeSelectorTerms(NodeSelectorTerm... items){
            for (NodeSelectorTerm item : items) {NodeSelectorTermBuilder builder = new NodeSelectorTermBuilder(item);_visitables.add(builder);this.nodeSelectorTerms.add(builder);} return (A)this;
    }

    public A addAllToNodeSelectorTerms(Collection items){
            for (NodeSelectorTerm item : items) {NodeSelectorTermBuilder builder = new NodeSelectorTermBuilder(item);_visitables.add(builder);this.nodeSelectorTerms.add(builder);} return (A)this;
    }

    public A removeFromNodeSelectorTerms(NodeSelectorTerm... items){
            for (NodeSelectorTerm item : items) {NodeSelectorTermBuilder builder = new NodeSelectorTermBuilder(item);_visitables.remove(builder);this.nodeSelectorTerms.remove(builder);} return (A)this;
    }

    public A removeAllFromNodeSelectorTerms(Collection items){
            for (NodeSelectorTerm item : items) {NodeSelectorTermBuilder builder = new NodeSelectorTermBuilder(item);_visitables.remove(builder);this.nodeSelectorTerms.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildNodeSelectorTerms instead.
 */
@Deprecated public List getNodeSelectorTerms(){
            return build(nodeSelectorTerms);
    }

    public List buildNodeSelectorTerms(){
            return build(nodeSelectorTerms);
    }

    public NodeSelectorTerm buildNodeSelectorTerm(int index){
            return this.nodeSelectorTerms.get(index).build();
    }

    public NodeSelectorTerm buildFirstNodeSelectorTerm(){
            return this.nodeSelectorTerms.get(0).build();
    }

    public NodeSelectorTerm buildLastNodeSelectorTerm(){
            return this.nodeSelectorTerms.get(nodeSelectorTerms.size() - 1).build();
    }

    public NodeSelectorTerm buildMatchingNodeSelectorTerm(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (NodeSelectorTermBuilder item: nodeSelectorTerms) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withNodeSelectorTerms(List nodeSelectorTerms){
            _visitables.removeAll(this.nodeSelectorTerms);
            this.nodeSelectorTerms.clear();
            if (nodeSelectorTerms != null) {for (NodeSelectorTerm item : nodeSelectorTerms){this.addToNodeSelectorTerms(item);}} return (A) this;
    }

    public A withNodeSelectorTerms(NodeSelectorTerm... nodeSelectorTerms){
            this.nodeSelectorTerms.clear(); if (nodeSelectorTerms != null) {for (NodeSelectorTerm item :nodeSelectorTerms){ this.addToNodeSelectorTerms(item);}} return (A) this;
    }

    public Boolean hasNodeSelectorTerms(){
            return nodeSelectorTerms!= null && !nodeSelectorTerms.isEmpty();
    }

    public NodeSelectorFluent.NodeSelectorTermsNested addNewNodeSelectorTerm(){
            return new NodeSelectorTermsNestedImpl();
    }

    public NodeSelectorFluent.NodeSelectorTermsNested addNewNodeSelectorTermLike(NodeSelectorTerm item){
            return new NodeSelectorTermsNestedImpl(-1, item);
    }

    public NodeSelectorFluent.NodeSelectorTermsNested setNewNodeSelectorTermLike(int index,NodeSelectorTerm item){
            return new NodeSelectorTermsNestedImpl(index, item);
    }

    public NodeSelectorFluent.NodeSelectorTermsNested editNodeSelectorTerm(int index){
            if (nodeSelectorTerms.size() <= index) throw new RuntimeException("Can't edit nodeSelectorTerms. Index exceeds size.");
            return setNewNodeSelectorTermLike(index, buildNodeSelectorTerm(index));
    }

    public NodeSelectorFluent.NodeSelectorTermsNested editFirstNodeSelectorTerm(){
            if (nodeSelectorTerms.size() == 0) throw new RuntimeException("Can't edit first nodeSelectorTerms. The list is empty.");
            return setNewNodeSelectorTermLike(0, buildNodeSelectorTerm(0));
    }

    public NodeSelectorFluent.NodeSelectorTermsNested editLastNodeSelectorTerm(){
            int index = nodeSelectorTerms.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last nodeSelectorTerms. The list is empty.");
            return setNewNodeSelectorTermLike(index, buildNodeSelectorTerm(index));
    }

    public NodeSelectorFluent.NodeSelectorTermsNested editMatchingNodeSelectorTerm(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends NodeSelectorTermFluentImpl> implements NodeSelectorFluent.NodeSelectorTermsNested,io.alauda.kubernetes.api.builder.Nested{

            private final NodeSelectorTermBuilder builder;
        private final int index;
    
            NodeSelectorTermsNestedImpl(int index,NodeSelectorTerm item){
                    this.index = index;
                    this.builder = new NodeSelectorTermBuilder(this, item);
            }
            NodeSelectorTermsNestedImpl(){
                    this.index = -1;
                    this.builder = new NodeSelectorTermBuilder(this);
            }
    
    public N and(){
            return (N) NodeSelectorFluentImpl.this.setToNodeSelectorTerms(index, builder.build());
    }
    public N endNodeSelectorTerm(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy