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

annotations.io.alauda.kubernetes.api.model.NodeSpecFluentImpl 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 com.fasterxml.jackson.annotation.JsonInclude;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
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 NodeSpecFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements NodeSpecFluent{

    private String externalID;
    private String podCIDR;
    private String providerID;
    private List taints =  new ArrayList();
    private Boolean unschedulable;

    public NodeSpecFluentImpl(){
    }
    public NodeSpecFluentImpl(NodeSpec instance){
            this.withExternalID(instance.getExternalID()); 
            this.withPodCIDR(instance.getPodCIDR()); 
            this.withProviderID(instance.getProviderID()); 
            this.withTaints(instance.getTaints()); 
            this.withUnschedulable(instance.getUnschedulable()); 
    }

    public String getExternalID(){
            return this.externalID;
    }

    public A withExternalID(String externalID){
            this.externalID=externalID; return (A) this;
    }

    public Boolean hasExternalID(){
            return this.externalID!=null;
    }

    public String getPodCIDR(){
            return this.podCIDR;
    }

    public A withPodCIDR(String podCIDR){
            this.podCIDR=podCIDR; return (A) this;
    }

    public Boolean hasPodCIDR(){
            return this.podCIDR!=null;
    }

    public String getProviderID(){
            return this.providerID;
    }

    public A withProviderID(String providerID){
            this.providerID=providerID; return (A) this;
    }

    public Boolean hasProviderID(){
            return this.providerID!=null;
    }

    public A addToTaints(int index,Taint item){
            TaintBuilder builder = new TaintBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.taints.add(index >= 0 ? index : taints.size(), builder); return (A)this;
    }

    public A setToTaints(int index,Taint item){
            TaintBuilder builder = new TaintBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= taints.size()) { taints.add(builder); } else { taints.set(index, builder);}
             return (A)this;
    }

    public A addToTaints(Taint... items){
            for (Taint item : items) {TaintBuilder builder = new TaintBuilder(item);_visitables.add(builder);this.taints.add(builder);} return (A)this;
    }

    public A addAllToTaints(Collection items){
            for (Taint item : items) {TaintBuilder builder = new TaintBuilder(item);_visitables.add(builder);this.taints.add(builder);} return (A)this;
    }

    public A removeFromTaints(Taint... items){
            for (Taint item : items) {TaintBuilder builder = new TaintBuilder(item);_visitables.remove(builder);this.taints.remove(builder);} return (A)this;
    }

    public A removeAllFromTaints(Collection items){
            for (Taint item : items) {TaintBuilder builder = new TaintBuilder(item);_visitables.remove(builder);this.taints.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildTaints instead.
 */
@Deprecated public List getTaints(){
            return build(taints);
    }

    public List buildTaints(){
            return build(taints);
    }

    public Taint buildTaint(int index){
            return this.taints.get(index).build();
    }

    public Taint buildFirstTaint(){
            return this.taints.get(0).build();
    }

    public Taint buildLastTaint(){
            return this.taints.get(taints.size() - 1).build();
    }

    public Taint buildMatchingTaint(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (TaintBuilder item: taints) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withTaints(List taints){
            _visitables.removeAll(this.taints);
            this.taints.clear();
            if (taints != null) {for (Taint item : taints){this.addToTaints(item);}} return (A) this;
    }

    public A withTaints(Taint... taints){
            this.taints.clear(); if (taints != null) {for (Taint item :taints){ this.addToTaints(item);}} return (A) this;
    }

    public Boolean hasTaints(){
            return taints!= null && !taints.isEmpty();
    }

    public NodeSpecFluent.TaintsNested addNewTaint(){
            return new TaintsNestedImpl();
    }

    public NodeSpecFluent.TaintsNested addNewTaintLike(Taint item){
            return new TaintsNestedImpl(-1, item);
    }

    public NodeSpecFluent.TaintsNested setNewTaintLike(int index,Taint item){
            return new TaintsNestedImpl(index, item);
    }

    public NodeSpecFluent.TaintsNested editTaint(int index){
            if (taints.size() <= index) throw new RuntimeException("Can't edit taints. Index exceeds size.");
            return setNewTaintLike(index, buildTaint(index));
    }

    public NodeSpecFluent.TaintsNested editFirstTaint(){
            if (taints.size() == 0) throw new RuntimeException("Can't edit first taints. The list is empty.");
            return setNewTaintLike(0, buildTaint(0));
    }

    public NodeSpecFluent.TaintsNested editLastTaint(){
            int index = taints.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last taints. The list is empty.");
            return setNewTaintLike(index, buildTaint(index));
    }

    public NodeSpecFluent.TaintsNested editMatchingTaint(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends TaintFluentImpl> implements NodeSpecFluent.TaintsNested,io.alauda.kubernetes.api.builder.Nested{

            private final TaintBuilder builder;
        private final int index;
    
            TaintsNestedImpl(int index,Taint item){
                    this.index = index;
                    this.builder = new TaintBuilder(this, item);
            }
            TaintsNestedImpl(){
                    this.index = -1;
                    this.builder = new TaintBuilder(this);
            }
    
    public N and(){
            return (N) NodeSpecFluentImpl.this.setToTaints(index, builder.build());
    }
    public N endTaint(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy