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

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

    private List drivers;

    public V1beta1CSINodeSpecFluentImpl() { 
    }


    public V1beta1CSINodeSpecFluentImpl(V1beta1CSINodeSpec instance) { 
        this.withDrivers(instance.getDrivers());

    }


    public A addToDrivers(int index,V1beta1CSINodeDriver item) {
        if (this.drivers == null) {this.drivers = new ArrayList();}
        V1beta1CSINodeDriverBuilder builder = new V1beta1CSINodeDriverBuilder(item);_visitables.get("drivers").add(index >= 0 ? index : _visitables.get("drivers").size(), builder);this.drivers.add(index >= 0 ? index : drivers.size(), builder); return (A)this;
    }

    public A setToDrivers(int index,V1beta1CSINodeDriver item) {
        if (this.drivers == null) {this.drivers = new ArrayList();}
        V1beta1CSINodeDriverBuilder builder = new V1beta1CSINodeDriverBuilder(item);
        if (index < 0 || index >= _visitables.get("drivers").size()) { _visitables.get("drivers").add(builder); } else { _visitables.get("drivers").set(index, builder);}
        if (index < 0 || index >= drivers.size()) { drivers.add(builder); } else { drivers.set(index, builder);}
         return (A)this;
    }

    public A addToDrivers(V1beta1CSINodeDriver... items) {
        if (this.drivers == null) {this.drivers = new ArrayList();}
        for (V1beta1CSINodeDriver item : items) {V1beta1CSINodeDriverBuilder builder = new V1beta1CSINodeDriverBuilder(item);_visitables.get("drivers").add(builder);this.drivers.add(builder);} return (A)this;
    }

    public A addAllToDrivers(Collection items) {
        if (this.drivers == null) {this.drivers = new ArrayList();}
        for (V1beta1CSINodeDriver item : items) {V1beta1CSINodeDriverBuilder builder = new V1beta1CSINodeDriverBuilder(item);_visitables.get("drivers").add(builder);this.drivers.add(builder);} return (A)this;
    }

    public A removeFromDrivers(V1beta1CSINodeDriver... items) {
        for (V1beta1CSINodeDriver item : items) {V1beta1CSINodeDriverBuilder builder = new V1beta1CSINodeDriverBuilder(item);_visitables.get("drivers").remove(builder);if (this.drivers != null) {this.drivers.remove(builder);}} return (A)this;
    }

    public A removeAllFromDrivers(Collection items) {
        for (V1beta1CSINodeDriver item : items) {V1beta1CSINodeDriverBuilder builder = new V1beta1CSINodeDriverBuilder(item);_visitables.get("drivers").remove(builder);if (this.drivers != null) {this.drivers.remove(builder);}} return (A)this;
    }

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

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

    public List buildDrivers() {
        return build(drivers);
    }

    public V1beta1CSINodeDriver buildDriver(int index) {
        return this.drivers.get(index).build();
    }

    public V1beta1CSINodeDriver buildFirstDriver() {
        return this.drivers.get(0).build();
    }

    public V1beta1CSINodeDriver buildLastDriver() {
        return this.drivers.get(drivers.size() - 1).build();
    }

    public V1beta1CSINodeDriver buildMatchingDriver(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1beta1CSINodeDriverBuilder item: drivers) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingDriver(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1beta1CSINodeDriverBuilder item: drivers) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withDrivers(List drivers) {
        if (this.drivers != null) { _visitables.get("drivers").removeAll(this.drivers);}
        if (drivers != null) {this.drivers = new ArrayList(); for (V1beta1CSINodeDriver item : drivers){this.addToDrivers(item);}} else { this.drivers = null;} return (A) this;
    }

    public A withDrivers(V1beta1CSINodeDriver... drivers) {
        if (this.drivers != null) {this.drivers.clear();}
        if (drivers != null) {for (V1beta1CSINodeDriver item :drivers){ this.addToDrivers(item);}} return (A) this;
    }

    public Boolean hasDrivers() {
        return drivers != null && !drivers.isEmpty();
    }

    public V1beta1CSINodeSpecFluent.DriversNested addNewDriver() {
        return new DriversNestedImpl();
    }

    public V1beta1CSINodeSpecFluent.DriversNested addNewDriverLike(V1beta1CSINodeDriver item) {
        return new DriversNestedImpl(-1, item);
    }

    public V1beta1CSINodeSpecFluent.DriversNested setNewDriverLike(int index,V1beta1CSINodeDriver item) {
        return new DriversNestedImpl(index, item);
    }

    public V1beta1CSINodeSpecFluent.DriversNested editDriver(int index) {
        if (drivers.size() <= index) throw new RuntimeException("Can't edit drivers. Index exceeds size.");
        return setNewDriverLike(index, buildDriver(index));
    }

    public V1beta1CSINodeSpecFluent.DriversNested editFirstDriver() {
        if (drivers.size() == 0) throw new RuntimeException("Can't edit first drivers. The list is empty.");
        return setNewDriverLike(0, buildDriver(0));
    }

    public V1beta1CSINodeSpecFluent.DriversNested editLastDriver() {
        int index = drivers.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last drivers. The list is empty.");
        return setNewDriverLike(index, buildDriver(index));
    }

    public V1beta1CSINodeSpecFluent.DriversNested editMatchingDriver(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i extends V1beta1CSINodeDriverFluentImpl> implements V1beta1CSINodeSpecFluent.DriversNested,io.kubernetes.client.fluent.Nested {
        private final V1beta1CSINodeDriverBuilder builder;
        private final int index;

        DriversNestedImpl(int index,V1beta1CSINodeDriver item) {
            this.index = index;
            this.builder = new V1beta1CSINodeDriverBuilder(this, item);
        }

        DriversNestedImpl() {
            this.index = -1;
            this.builder = new V1beta1CSINodeDriverBuilder(this);
        }

        public N and() {
             return (N) V1beta1CSINodeSpecFluentImpl.this.setToDrivers(index,builder.build());
        }

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


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy