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

io.kubernetes.client.openapi.models.V1ProjectedVolumeSourceFluentImpl 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.Integer;
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 V1ProjectedVolumeSourceFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1ProjectedVolumeSourceFluent {

    private Integer defaultMode;
    private List sources;

    public V1ProjectedVolumeSourceFluentImpl() { 
    }


    public V1ProjectedVolumeSourceFluentImpl(V1ProjectedVolumeSource instance) { 
        this.withDefaultMode(instance.getDefaultMode());

        this.withSources(instance.getSources());

    }


    public Integer getDefaultMode() {
        return this.defaultMode;
    }

    public A withDefaultMode(Integer defaultMode) {
        this.defaultMode=defaultMode; return (A) this;
    }

    public Boolean hasDefaultMode() {
        return this.defaultMode != null;
    }

    public A addToSources(int index,V1VolumeProjection item) {
        if (this.sources == null) {this.sources = new ArrayList();}
        V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").add(index >= 0 ? index : _visitables.get("sources").size(), builder);this.sources.add(index >= 0 ? index : sources.size(), builder); return (A)this;
    }

    public A setToSources(int index,V1VolumeProjection item) {
        if (this.sources == null) {this.sources = new ArrayList();}
        V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);
        if (index < 0 || index >= _visitables.get("sources").size()) { _visitables.get("sources").add(builder); } else { _visitables.get("sources").set(index, builder);}
        if (index < 0 || index >= sources.size()) { sources.add(builder); } else { sources.set(index, builder);}
         return (A)this;
    }

    public A addToSources(V1VolumeProjection... items) {
        if (this.sources == null) {this.sources = new ArrayList();}
        for (V1VolumeProjection item : items) {V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").add(builder);this.sources.add(builder);} return (A)this;
    }

    public A addAllToSources(Collection items) {
        if (this.sources == null) {this.sources = new ArrayList();}
        for (V1VolumeProjection item : items) {V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").add(builder);this.sources.add(builder);} return (A)this;
    }

    public A removeFromSources(V1VolumeProjection... items) {
        for (V1VolumeProjection item : items) {V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").remove(builder);if (this.sources != null) {this.sources.remove(builder);}} return (A)this;
    }

    public A removeAllFromSources(Collection items) {
        for (V1VolumeProjection item : items) {V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").remove(builder);if (this.sources != null) {this.sources.remove(builder);}} return (A)this;
    }

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

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

    public List buildSources() {
        return build(sources);
    }

    public V1VolumeProjection buildSource(int index) {
        return this.sources.get(index).build();
    }

    public V1VolumeProjection buildFirstSource() {
        return this.sources.get(0).build();
    }

    public V1VolumeProjection buildLastSource() {
        return this.sources.get(sources.size() - 1).build();
    }

    public V1VolumeProjection buildMatchingSource(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1VolumeProjectionBuilder item: sources) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingSource(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1VolumeProjectionBuilder item: sources) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withSources(List sources) {
        if (this.sources != null) { _visitables.get("sources").removeAll(this.sources);}
        if (sources != null) {this.sources = new ArrayList(); for (V1VolumeProjection item : sources){this.addToSources(item);}} else { this.sources = null;} return (A) this;
    }

    public A withSources(V1VolumeProjection... sources) {
        if (this.sources != null) {this.sources.clear();}
        if (sources != null) {for (V1VolumeProjection item :sources){ this.addToSources(item);}} return (A) this;
    }

    public Boolean hasSources() {
        return sources != null && !sources.isEmpty();
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested addNewSource() {
        return new SourcesNestedImpl();
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested addNewSourceLike(V1VolumeProjection item) {
        return new SourcesNestedImpl(-1, item);
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested setNewSourceLike(int index,V1VolumeProjection item) {
        return new SourcesNestedImpl(index, item);
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested editSource(int index) {
        if (sources.size() <= index) throw new RuntimeException("Can't edit sources. Index exceeds size.");
        return setNewSourceLike(index, buildSource(index));
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested editFirstSource() {
        if (sources.size() == 0) throw new RuntimeException("Can't edit first sources. The list is empty.");
        return setNewSourceLike(0, buildSource(0));
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested editLastSource() {
        int index = sources.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last sources. The list is empty.");
        return setNewSourceLike(index, buildSource(index));
    }

    public V1ProjectedVolumeSourceFluent.SourcesNested editMatchingSource(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i extends V1VolumeProjectionFluentImpl> implements V1ProjectedVolumeSourceFluent.SourcesNested,io.kubernetes.client.fluent.Nested {
        private final V1VolumeProjectionBuilder builder;
        private final int index;

        SourcesNestedImpl(int index,V1VolumeProjection item) {
            this.index = index;
            this.builder = new V1VolumeProjectionBuilder(this, item);
        }

        SourcesNestedImpl() {
            this.index = -1;
            this.builder = new V1VolumeProjectionBuilder(this);
        }

        public N and() {
             return (N) V1ProjectedVolumeSourceFluentImpl.this.setToSources(index,builder.build());
        }

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


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy