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

io.kubernetes.client.openapi.models.V1NodeSelectorFluentImpl Maven / Gradle / Ivy

There is a newer version: 22.0.0
Show newest version
package io.kubernetes.client.openapi.models;

import io.kubernetes.client.fluent.VisitableBuilder;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import io.kubernetes.client.fluent.Predicate;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class V1NodeSelectorFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1NodeSelectorFluent {

    private List nodeSelectorTerms;

    public V1NodeSelectorFluentImpl() { 
    }


    public V1NodeSelectorFluentImpl(V1NodeSelector instance) { 
        this.withNodeSelectorTerms(instance.getNodeSelectorTerms());

    }


    public A addToNodeSelectorTerms(int index,V1NodeSelectorTerm item) {
        if (this.nodeSelectorTerms == null) {this.nodeSelectorTerms = new ArrayList();}
        V1NodeSelectorTermBuilder builder = new V1NodeSelectorTermBuilder(item);_visitables.get("nodeSelectorTerms").add(index >= 0 ? index : _visitables.get("nodeSelectorTerms").size(), builder);this.nodeSelectorTerms.add(index >= 0 ? index : nodeSelectorTerms.size(), builder); return (A)this;
    }

    public A setToNodeSelectorTerms(int index,V1NodeSelectorTerm item) {
        if (this.nodeSelectorTerms == null) {this.nodeSelectorTerms = new ArrayList();}
        V1NodeSelectorTermBuilder builder = new V1NodeSelectorTermBuilder(item);
        if (index < 0 || index >= _visitables.get("nodeSelectorTerms").size()) { _visitables.get("nodeSelectorTerms").add(builder); } else { _visitables.get("nodeSelectorTerms").set(index, builder);}
        if (index < 0 || index >= nodeSelectorTerms.size()) { nodeSelectorTerms.add(builder); } else { nodeSelectorTerms.set(index, builder);}
         return (A)this;
    }

    public A addToNodeSelectorTerms(V1NodeSelectorTerm... items) {
        if (this.nodeSelectorTerms == null) {this.nodeSelectorTerms = new ArrayList();}
        for (V1NodeSelectorTerm item : items) {V1NodeSelectorTermBuilder builder = new V1NodeSelectorTermBuilder(item);_visitables.get("nodeSelectorTerms").add(builder);this.nodeSelectorTerms.add(builder);} return (A)this;
    }

    public A addAllToNodeSelectorTerms(Collection items) {
        if (this.nodeSelectorTerms == null) {this.nodeSelectorTerms = new ArrayList();}
        for (V1NodeSelectorTerm item : items) {V1NodeSelectorTermBuilder builder = new V1NodeSelectorTermBuilder(item);_visitables.get("nodeSelectorTerms").add(builder);this.nodeSelectorTerms.add(builder);} return (A)this;
    }

    public A removeFromNodeSelectorTerms(V1NodeSelectorTerm... items) {
        for (V1NodeSelectorTerm item : items) {V1NodeSelectorTermBuilder builder = new V1NodeSelectorTermBuilder(item);_visitables.get("nodeSelectorTerms").remove(builder);if (this.nodeSelectorTerms != null) {this.nodeSelectorTerms.remove(builder);}} return (A)this;
    }

    public A removeAllFromNodeSelectorTerms(Collection items) {
        for (V1NodeSelectorTerm item : items) {V1NodeSelectorTermBuilder builder = new V1NodeSelectorTermBuilder(item);_visitables.get("nodeSelectorTerms").remove(builder);if (this.nodeSelectorTerms != null) {this.nodeSelectorTerms.remove(builder);}} return (A)this;
    }

    public A removeMatchingFromNodeSelectorTerms(io.kubernetes.client.fluent.Predicate predicate) {
        if (nodeSelectorTerms == null) return (A) this;
        final Iterator each = nodeSelectorTerms.iterator();
        final List visitables = _visitables.get("nodeSelectorTerms");
        while (each.hasNext()) {
          V1NodeSelectorTermBuilder builder = each.next();
          if (predicate.apply(builder)) {
            visitables.remove(builder);
            each.remove();
          }
        }
        return (A)this;
    }

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

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

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

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

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

    public V1NodeSelectorTerm buildMatchingNodeSelectorTerm(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1NodeSelectorTermBuilder item: nodeSelectorTerms) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingNodeSelectorTerm(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1NodeSelectorTermBuilder item: nodeSelectorTerms) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withNodeSelectorTerms(List nodeSelectorTerms) {
        if (this.nodeSelectorTerms != null) { _visitables.get("nodeSelectorTerms").removeAll(this.nodeSelectorTerms);}
        if (nodeSelectorTerms != null) {this.nodeSelectorTerms = new ArrayList(); for (V1NodeSelectorTerm item : nodeSelectorTerms){this.addToNodeSelectorTerms(item);}} else { this.nodeSelectorTerms = null;} return (A) this;
    }

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

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

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

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

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

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

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

    public V1NodeSelectorFluent.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 V1NodeSelectorFluent.NodeSelectorTermsNested editMatchingNodeSelectorTerm(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i extends V1NodeSelectorTermFluentImpl> implements V1NodeSelectorFluent.NodeSelectorTermsNested,io.kubernetes.client.fluent.Nested {
        private final V1NodeSelectorTermBuilder builder;
        private final int index;

        NodeSelectorTermsNestedImpl(int index,V1NodeSelectorTerm item) {
            this.index = index;
            this.builder = new V1NodeSelectorTermBuilder(this, item);
        }

        NodeSelectorTermsNestedImpl() {
            this.index = -1;
            this.builder = new V1NodeSelectorTermBuilder(this);
        }

        public N and() {
             return (N) V1NodeSelectorFluentImpl.this.setToNodeSelectorTerms(index,builder.build());
        }

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


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy