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

io.kubernetes.client.openapi.models.V1PodAntiAffinityFluentImpl 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.List;
import java.lang.Boolean;
import java.util.Collection;
import java.lang.Object;

public class V1PodAntiAffinityFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1PodAntiAffinityFluent {

    private List preferredDuringSchedulingIgnoredDuringExecution;
    private List requiredDuringSchedulingIgnoredDuringExecution;

    public V1PodAntiAffinityFluentImpl() { 
    }


    public V1PodAntiAffinityFluentImpl(V1PodAntiAffinity instance) { 
        this.withPreferredDuringSchedulingIgnoredDuringExecution(instance.getPreferredDuringSchedulingIgnoredDuringExecution());

        this.withRequiredDuringSchedulingIgnoredDuringExecution(instance.getRequiredDuringSchedulingIgnoredDuringExecution());

    }


    public A addToPreferredDuringSchedulingIgnoredDuringExecution(int index,V1WeightedPodAffinityTerm item) {
        if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        V1WeightedPodAffinityTermBuilder builder = new V1WeightedPodAffinityTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(index >= 0 ? index : _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").size(), builder);this.preferredDuringSchedulingIgnoredDuringExecution.add(index >= 0 ? index : preferredDuringSchedulingIgnoredDuringExecution.size(), builder); return (A)this;
    }

    public A setToPreferredDuringSchedulingIgnoredDuringExecution(int index,V1WeightedPodAffinityTerm item) {
        if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        V1WeightedPodAffinityTermBuilder builder = new V1WeightedPodAffinityTermBuilder(item);
        if (index < 0 || index >= _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").size()) { _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(builder); } else { _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").set(index, builder);}
        if (index < 0 || index >= preferredDuringSchedulingIgnoredDuringExecution.size()) { preferredDuringSchedulingIgnoredDuringExecution.add(builder); } else { preferredDuringSchedulingIgnoredDuringExecution.set(index, builder);}
         return (A)this;
    }

    public A addToPreferredDuringSchedulingIgnoredDuringExecution(V1WeightedPodAffinityTerm... items) {
        if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        for (V1WeightedPodAffinityTerm item : items) {V1WeightedPodAffinityTermBuilder builder = new V1WeightedPodAffinityTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(builder);this.preferredDuringSchedulingIgnoredDuringExecution.add(builder);} return (A)this;
    }

    public A addAllToPreferredDuringSchedulingIgnoredDuringExecution(Collection items) {
        if (this.preferredDuringSchedulingIgnoredDuringExecution == null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        for (V1WeightedPodAffinityTerm item : items) {V1WeightedPodAffinityTermBuilder builder = new V1WeightedPodAffinityTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").add(builder);this.preferredDuringSchedulingIgnoredDuringExecution.add(builder);} return (A)this;
    }

    public A removeFromPreferredDuringSchedulingIgnoredDuringExecution(V1WeightedPodAffinityTerm... items) {
        for (V1WeightedPodAffinityTerm item : items) {V1WeightedPodAffinityTermBuilder builder = new V1WeightedPodAffinityTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").remove(builder);if (this.preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution.remove(builder);}} return (A)this;
    }

    public A removeAllFromPreferredDuringSchedulingIgnoredDuringExecution(Collection items) {
        for (V1WeightedPodAffinityTerm item : items) {V1WeightedPodAffinityTermBuilder builder = new V1WeightedPodAffinityTermBuilder(item);_visitables.get("preferredDuringSchedulingIgnoredDuringExecution").remove(builder);if (this.preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution.remove(builder);}} return (A)this;
    }

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

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

    public List buildPreferredDuringSchedulingIgnoredDuringExecution() {
        return build(preferredDuringSchedulingIgnoredDuringExecution);
    }

    public V1WeightedPodAffinityTerm buildPreferredDuringSchedulingIgnoredDuringExecution(int index) {
        return this.preferredDuringSchedulingIgnoredDuringExecution.get(index).build();
    }

    public V1WeightedPodAffinityTerm buildFirstPreferredDuringSchedulingIgnoredDuringExecution() {
        return this.preferredDuringSchedulingIgnoredDuringExecution.get(0).build();
    }

    public V1WeightedPodAffinityTerm buildLastPreferredDuringSchedulingIgnoredDuringExecution() {
        return this.preferredDuringSchedulingIgnoredDuringExecution.get(preferredDuringSchedulingIgnoredDuringExecution.size() - 1).build();
    }

    public V1WeightedPodAffinityTerm buildMatchingPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1WeightedPodAffinityTermBuilder item: preferredDuringSchedulingIgnoredDuringExecution) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1WeightedPodAffinityTermBuilder item: preferredDuringSchedulingIgnoredDuringExecution) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withPreferredDuringSchedulingIgnoredDuringExecution(List preferredDuringSchedulingIgnoredDuringExecution) {
        if (this.preferredDuringSchedulingIgnoredDuringExecution != null) { _visitables.get("preferredDuringSchedulingIgnoredDuringExecution").removeAll(this.preferredDuringSchedulingIgnoredDuringExecution);}
        if (preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution = new ArrayList(); for (V1WeightedPodAffinityTerm item : preferredDuringSchedulingIgnoredDuringExecution){this.addToPreferredDuringSchedulingIgnoredDuringExecution(item);}} else { this.preferredDuringSchedulingIgnoredDuringExecution = null;} return (A) this;
    }

    public A withPreferredDuringSchedulingIgnoredDuringExecution(V1WeightedPodAffinityTerm... preferredDuringSchedulingIgnoredDuringExecution) {
        if (this.preferredDuringSchedulingIgnoredDuringExecution != null) {this.preferredDuringSchedulingIgnoredDuringExecution.clear();}
        if (preferredDuringSchedulingIgnoredDuringExecution != null) {for (V1WeightedPodAffinityTerm item :preferredDuringSchedulingIgnoredDuringExecution){ this.addToPreferredDuringSchedulingIgnoredDuringExecution(item);}} return (A) this;
    }

    public Boolean hasPreferredDuringSchedulingIgnoredDuringExecution() {
        return preferredDuringSchedulingIgnoredDuringExecution != null && !preferredDuringSchedulingIgnoredDuringExecution.isEmpty();
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested addNewPreferredDuringSchedulingIgnoredDuringExecution() {
        return new PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl();
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested addNewPreferredDuringSchedulingIgnoredDuringExecutionLike(V1WeightedPodAffinityTerm item) {
        return new PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl(-1, item);
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(int index,V1WeightedPodAffinityTerm item) {
        return new PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl(index, item);
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editPreferredDuringSchedulingIgnoredDuringExecution(int index) {
        if (preferredDuringSchedulingIgnoredDuringExecution.size() <= index) throw new RuntimeException("Can't edit preferredDuringSchedulingIgnoredDuringExecution. Index exceeds size.");
        return setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(index, buildPreferredDuringSchedulingIgnoredDuringExecution(index));
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editFirstPreferredDuringSchedulingIgnoredDuringExecution() {
        if (preferredDuringSchedulingIgnoredDuringExecution.size() == 0) throw new RuntimeException("Can't edit first preferredDuringSchedulingIgnoredDuringExecution. The list is empty.");
        return setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(0, buildPreferredDuringSchedulingIgnoredDuringExecution(0));
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editLastPreferredDuringSchedulingIgnoredDuringExecution() {
        int index = preferredDuringSchedulingIgnoredDuringExecution.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last preferredDuringSchedulingIgnoredDuringExecution. The list is empty.");
        return setNewPreferredDuringSchedulingIgnoredDuringExecutionLike(index, buildPreferredDuringSchedulingIgnoredDuringExecution(index));
    }

    public V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested editMatchingPreferredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i();}
        V1PodAffinityTermBuilder builder = new V1PodAffinityTermBuilder(item);_visitables.get("requiredDuringSchedulingIgnoredDuringExecution").add(index >= 0 ? index : _visitables.get("requiredDuringSchedulingIgnoredDuringExecution").size(), builder);this.requiredDuringSchedulingIgnoredDuringExecution.add(index >= 0 ? index : requiredDuringSchedulingIgnoredDuringExecution.size(), builder); return (A)this;
    }

    public A setToRequiredDuringSchedulingIgnoredDuringExecution(int index,V1PodAffinityTerm item) {
        if (this.requiredDuringSchedulingIgnoredDuringExecution == null) {this.requiredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        V1PodAffinityTermBuilder builder = new V1PodAffinityTermBuilder(item);
        if (index < 0 || index >= _visitables.get("requiredDuringSchedulingIgnoredDuringExecution").size()) { _visitables.get("requiredDuringSchedulingIgnoredDuringExecution").add(builder); } else { _visitables.get("requiredDuringSchedulingIgnoredDuringExecution").set(index, builder);}
        if (index < 0 || index >= requiredDuringSchedulingIgnoredDuringExecution.size()) { requiredDuringSchedulingIgnoredDuringExecution.add(builder); } else { requiredDuringSchedulingIgnoredDuringExecution.set(index, builder);}
         return (A)this;
    }

    public A addToRequiredDuringSchedulingIgnoredDuringExecution(V1PodAffinityTerm... items) {
        if (this.requiredDuringSchedulingIgnoredDuringExecution == null) {this.requiredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        for (V1PodAffinityTerm item : items) {V1PodAffinityTermBuilder builder = new V1PodAffinityTermBuilder(item);_visitables.get("requiredDuringSchedulingIgnoredDuringExecution").add(builder);this.requiredDuringSchedulingIgnoredDuringExecution.add(builder);} return (A)this;
    }

    public A addAllToRequiredDuringSchedulingIgnoredDuringExecution(Collection items) {
        if (this.requiredDuringSchedulingIgnoredDuringExecution == null) {this.requiredDuringSchedulingIgnoredDuringExecution = new ArrayList();}
        for (V1PodAffinityTerm item : items) {V1PodAffinityTermBuilder builder = new V1PodAffinityTermBuilder(item);_visitables.get("requiredDuringSchedulingIgnoredDuringExecution").add(builder);this.requiredDuringSchedulingIgnoredDuringExecution.add(builder);} return (A)this;
    }

    public A removeFromRequiredDuringSchedulingIgnoredDuringExecution(V1PodAffinityTerm... items) {
        for (V1PodAffinityTerm item : items) {V1PodAffinityTermBuilder builder = new V1PodAffinityTermBuilder(item);_visitables.get("requiredDuringSchedulingIgnoredDuringExecution").remove(builder);if (this.requiredDuringSchedulingIgnoredDuringExecution != null) {this.requiredDuringSchedulingIgnoredDuringExecution.remove(builder);}} return (A)this;
    }

    public A removeAllFromRequiredDuringSchedulingIgnoredDuringExecution(Collection items) {
        for (V1PodAffinityTerm item : items) {V1PodAffinityTermBuilder builder = new V1PodAffinityTermBuilder(item);_visitables.get("requiredDuringSchedulingIgnoredDuringExecution").remove(builder);if (this.requiredDuringSchedulingIgnoredDuringExecution != null) {this.requiredDuringSchedulingIgnoredDuringExecution.remove(builder);}} return (A)this;
    }

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

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

    public List buildRequiredDuringSchedulingIgnoredDuringExecution() {
        return build(requiredDuringSchedulingIgnoredDuringExecution);
    }

    public V1PodAffinityTerm buildRequiredDuringSchedulingIgnoredDuringExecution(int index) {
        return this.requiredDuringSchedulingIgnoredDuringExecution.get(index).build();
    }

    public V1PodAffinityTerm buildFirstRequiredDuringSchedulingIgnoredDuringExecution() {
        return this.requiredDuringSchedulingIgnoredDuringExecution.get(0).build();
    }

    public V1PodAffinityTerm buildLastRequiredDuringSchedulingIgnoredDuringExecution() {
        return this.requiredDuringSchedulingIgnoredDuringExecution.get(requiredDuringSchedulingIgnoredDuringExecution.size() - 1).build();
    }

    public V1PodAffinityTerm buildMatchingRequiredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1PodAffinityTermBuilder item: requiredDuringSchedulingIgnoredDuringExecution) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingRequiredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1PodAffinityTermBuilder item: requiredDuringSchedulingIgnoredDuringExecution) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withRequiredDuringSchedulingIgnoredDuringExecution(List requiredDuringSchedulingIgnoredDuringExecution) {
        if (this.requiredDuringSchedulingIgnoredDuringExecution != null) { _visitables.get("requiredDuringSchedulingIgnoredDuringExecution").removeAll(this.requiredDuringSchedulingIgnoredDuringExecution);}
        if (requiredDuringSchedulingIgnoredDuringExecution != null) {this.requiredDuringSchedulingIgnoredDuringExecution = new ArrayList(); for (V1PodAffinityTerm item : requiredDuringSchedulingIgnoredDuringExecution){this.addToRequiredDuringSchedulingIgnoredDuringExecution(item);}} else { this.requiredDuringSchedulingIgnoredDuringExecution = null;} return (A) this;
    }

    public A withRequiredDuringSchedulingIgnoredDuringExecution(V1PodAffinityTerm... requiredDuringSchedulingIgnoredDuringExecution) {
        if (this.requiredDuringSchedulingIgnoredDuringExecution != null) {this.requiredDuringSchedulingIgnoredDuringExecution.clear();}
        if (requiredDuringSchedulingIgnoredDuringExecution != null) {for (V1PodAffinityTerm item :requiredDuringSchedulingIgnoredDuringExecution){ this.addToRequiredDuringSchedulingIgnoredDuringExecution(item);}} return (A) this;
    }

    public Boolean hasRequiredDuringSchedulingIgnoredDuringExecution() {
        return requiredDuringSchedulingIgnoredDuringExecution != null && !requiredDuringSchedulingIgnoredDuringExecution.isEmpty();
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested addNewRequiredDuringSchedulingIgnoredDuringExecution() {
        return new RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl();
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested addNewRequiredDuringSchedulingIgnoredDuringExecutionLike(V1PodAffinityTerm item) {
        return new RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl(-1, item);
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested setNewRequiredDuringSchedulingIgnoredDuringExecutionLike(int index,V1PodAffinityTerm item) {
        return new RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl(index, item);
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editRequiredDuringSchedulingIgnoredDuringExecution(int index) {
        if (requiredDuringSchedulingIgnoredDuringExecution.size() <= index) throw new RuntimeException("Can't edit requiredDuringSchedulingIgnoredDuringExecution. Index exceeds size.");
        return setNewRequiredDuringSchedulingIgnoredDuringExecutionLike(index, buildRequiredDuringSchedulingIgnoredDuringExecution(index));
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editFirstRequiredDuringSchedulingIgnoredDuringExecution() {
        if (requiredDuringSchedulingIgnoredDuringExecution.size() == 0) throw new RuntimeException("Can't edit first requiredDuringSchedulingIgnoredDuringExecution. The list is empty.");
        return setNewRequiredDuringSchedulingIgnoredDuringExecutionLike(0, buildRequiredDuringSchedulingIgnoredDuringExecution(0));
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editLastRequiredDuringSchedulingIgnoredDuringExecution() {
        int index = requiredDuringSchedulingIgnoredDuringExecution.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last requiredDuringSchedulingIgnoredDuringExecution. The list is empty.");
        return setNewRequiredDuringSchedulingIgnoredDuringExecutionLike(index, buildRequiredDuringSchedulingIgnoredDuringExecution(index));
    }

    public V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested editMatchingRequiredDuringSchedulingIgnoredDuringExecution(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i extends V1WeightedPodAffinityTermFluentImpl> implements V1PodAntiAffinityFluent.PreferredDuringSchedulingIgnoredDuringExecutionNested,io.kubernetes.client.fluent.Nested {
        private final V1WeightedPodAffinityTermBuilder builder;
        private final int index;

        PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl(int index,V1WeightedPodAffinityTerm item) {
            this.index = index;
            this.builder = new V1WeightedPodAffinityTermBuilder(this, item);
        }

        PreferredDuringSchedulingIgnoredDuringExecutionNestedImpl() {
            this.index = -1;
            this.builder = new V1WeightedPodAffinityTermBuilder(this);
        }

        public N and() {
             return (N) V1PodAntiAffinityFluentImpl.this.setToPreferredDuringSchedulingIgnoredDuringExecution(index,builder.build());
        }

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


    public class RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl extends V1PodAffinityTermFluentImpl> implements V1PodAntiAffinityFluent.RequiredDuringSchedulingIgnoredDuringExecutionNested,io.kubernetes.client.fluent.Nested {
        private final V1PodAffinityTermBuilder builder;
        private final int index;

        RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl(int index,V1PodAffinityTerm item) {
            this.index = index;
            this.builder = new V1PodAffinityTermBuilder(this, item);
        }

        RequiredDuringSchedulingIgnoredDuringExecutionNestedImpl() {
            this.index = -1;
            this.builder = new V1PodAffinityTermBuilder(this);
        }

        public N and() {
             return (N) V1PodAntiAffinityFluentImpl.this.setToRequiredDuringSchedulingIgnoredDuringExecution(index,builder.build());
        }

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


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy