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

io.kubernetes.client.openapi.models.V1alpha1AggregationRuleFluentImpl 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 V1alpha1AggregationRuleFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1alpha1AggregationRuleFluent {

    private List clusterRoleSelectors;

    public V1alpha1AggregationRuleFluentImpl() { 
    }


    public V1alpha1AggregationRuleFluentImpl(V1alpha1AggregationRule instance) { 
        this.withClusterRoleSelectors(instance.getClusterRoleSelectors());

    }


    public A addToClusterRoleSelectors(int index,V1LabelSelector item) {
        if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
        V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").add(index >= 0 ? index : _visitables.get("clusterRoleSelectors").size(), builder);this.clusterRoleSelectors.add(index >= 0 ? index : clusterRoleSelectors.size(), builder); return (A)this;
    }

    public A setToClusterRoleSelectors(int index,V1LabelSelector item) {
        if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
        V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);
        if (index < 0 || index >= _visitables.get("clusterRoleSelectors").size()) { _visitables.get("clusterRoleSelectors").add(builder); } else { _visitables.get("clusterRoleSelectors").set(index, builder);}
        if (index < 0 || index >= clusterRoleSelectors.size()) { clusterRoleSelectors.add(builder); } else { clusterRoleSelectors.set(index, builder);}
         return (A)this;
    }

    public A addToClusterRoleSelectors(V1LabelSelector... items) {
        if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
        for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").add(builder);this.clusterRoleSelectors.add(builder);} return (A)this;
    }

    public A addAllToClusterRoleSelectors(Collection items) {
        if (this.clusterRoleSelectors == null) {this.clusterRoleSelectors = new ArrayList();}
        for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").add(builder);this.clusterRoleSelectors.add(builder);} return (A)this;
    }

    public A removeFromClusterRoleSelectors(V1LabelSelector... items) {
        for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").remove(builder);if (this.clusterRoleSelectors != null) {this.clusterRoleSelectors.remove(builder);}} return (A)this;
    }

    public A removeAllFromClusterRoleSelectors(Collection items) {
        for (V1LabelSelector item : items) {V1LabelSelectorBuilder builder = new V1LabelSelectorBuilder(item);_visitables.get("clusterRoleSelectors").remove(builder);if (this.clusterRoleSelectors != null) {this.clusterRoleSelectors.remove(builder);}} return (A)this;
    }

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

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

    public List buildClusterRoleSelectors() {
        return build(clusterRoleSelectors);
    }

    public V1LabelSelector buildClusterRoleSelector(int index) {
        return this.clusterRoleSelectors.get(index).build();
    }

    public V1LabelSelector buildFirstClusterRoleSelector() {
        return this.clusterRoleSelectors.get(0).build();
    }

    public V1LabelSelector buildLastClusterRoleSelector() {
        return this.clusterRoleSelectors.get(clusterRoleSelectors.size() - 1).build();
    }

    public V1LabelSelector buildMatchingClusterRoleSelector(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1LabelSelectorBuilder item: clusterRoleSelectors) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingClusterRoleSelector(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1LabelSelectorBuilder item: clusterRoleSelectors) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withClusterRoleSelectors(List clusterRoleSelectors) {
        if (this.clusterRoleSelectors != null) { _visitables.get("clusterRoleSelectors").removeAll(this.clusterRoleSelectors);}
        if (clusterRoleSelectors != null) {this.clusterRoleSelectors = new ArrayList(); for (V1LabelSelector item : clusterRoleSelectors){this.addToClusterRoleSelectors(item);}} else { this.clusterRoleSelectors = null;} return (A) this;
    }

    public A withClusterRoleSelectors(V1LabelSelector... clusterRoleSelectors) {
        if (this.clusterRoleSelectors != null) {this.clusterRoleSelectors.clear();}
        if (clusterRoleSelectors != null) {for (V1LabelSelector item :clusterRoleSelectors){ this.addToClusterRoleSelectors(item);}} return (A) this;
    }

    public Boolean hasClusterRoleSelectors() {
        return clusterRoleSelectors != null && !clusterRoleSelectors.isEmpty();
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested addNewClusterRoleSelector() {
        return new ClusterRoleSelectorsNestedImpl();
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested addNewClusterRoleSelectorLike(V1LabelSelector item) {
        return new ClusterRoleSelectorsNestedImpl(-1, item);
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested setNewClusterRoleSelectorLike(int index,V1LabelSelector item) {
        return new ClusterRoleSelectorsNestedImpl(index, item);
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested editClusterRoleSelector(int index) {
        if (clusterRoleSelectors.size() <= index) throw new RuntimeException("Can't edit clusterRoleSelectors. Index exceeds size.");
        return setNewClusterRoleSelectorLike(index, buildClusterRoleSelector(index));
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested editFirstClusterRoleSelector() {
        if (clusterRoleSelectors.size() == 0) throw new RuntimeException("Can't edit first clusterRoleSelectors. The list is empty.");
        return setNewClusterRoleSelectorLike(0, buildClusterRoleSelector(0));
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested editLastClusterRoleSelector() {
        int index = clusterRoleSelectors.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last clusterRoleSelectors. The list is empty.");
        return setNewClusterRoleSelectorLike(index, buildClusterRoleSelector(index));
    }

    public V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested editMatchingClusterRoleSelector(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i extends V1LabelSelectorFluentImpl> implements V1alpha1AggregationRuleFluent.ClusterRoleSelectorsNested,io.kubernetes.client.fluent.Nested {
        private final V1LabelSelectorBuilder builder;
        private final int index;

        ClusterRoleSelectorsNestedImpl(int index,V1LabelSelector item) {
            this.index = index;
            this.builder = new V1LabelSelectorBuilder(this, item);
        }

        ClusterRoleSelectorsNestedImpl() {
            this.index = -1;
            this.builder = new V1LabelSelectorBuilder(this);
        }

        public N and() {
             return (N) V1alpha1AggregationRuleFluentImpl.this.setToClusterRoleSelectors(index,builder.build());
        }

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


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy