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

io.kubernetes.client.openapi.models.V1ProjectedVolumeSourceFluent Maven / Gradle / Ivy

package io.kubernetes.client.openapi.models;

import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.function.Predicate;
import java.lang.Integer;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class V1ProjectedVolumeSourceFluent> extends BaseFluent{
  public V1ProjectedVolumeSourceFluent() {
  }
  
  public V1ProjectedVolumeSourceFluent(V1ProjectedVolumeSource instance) {
    this.copyInstance(instance);
  }
  private Integer defaultMode;
  private ArrayList sources;
  
  protected void copyInstance(V1ProjectedVolumeSource instance) {
    instance = (instance != null ? instance : new V1ProjectedVolumeSource());
    if (instance != null) {
          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);
    if (index < 0 || index >= sources.size()) { _visitables.get("sources").add(builder); sources.add(builder); } else { _visitables.get("sources").add(index, builder); sources.add(index, 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 >= sources.size()) { _visitables.get("sources").add(builder); sources.add(builder); } else { _visitables.get("sources").set(index, builder); sources.set(index, builder);}
    return (A)this;
  }
  
  public A addToSources(io.kubernetes.client.openapi.models.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(io.kubernetes.client.openapi.models.V1VolumeProjection... items) {
    if (this.sources == null) return (A)this;
    for (V1VolumeProjection item : items) {V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").remove(builder); this.sources.remove(builder);} return (A)this;
  }
  
  public A removeAllFromSources(Collection items) {
    if (this.sources == null) return (A)this;
    for (V1VolumeProjection item : items) {V1VolumeProjectionBuilder builder = new V1VolumeProjectionBuilder(item);_visitables.get("sources").remove(builder); this.sources.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromSources(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.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildSources() {
    return this.sources != null ? build(sources) : null;
  }
  
  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(Predicate predicate) {
      for (V1VolumeProjectionBuilder item : sources) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingSource(Predicate predicate) {
      for (V1VolumeProjectionBuilder item : sources) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withSources(List sources) {
    if (this.sources != null) {
      this._visitables.get("sources").clear();
    }
    if (sources != null) {
        this.sources = new ArrayList();
        for (V1VolumeProjection item : sources) {
          this.addToSources(item);
        }
    } else {
      this.sources = null;
    }
    return (A) this;
  }
  
  public A withSources(io.kubernetes.client.openapi.models.V1VolumeProjection... sources) {
    if (this.sources != null) {
        this.sources.clear();
        _visitables.remove("sources");
    }
    if (sources != null) {
      for (V1VolumeProjection item : sources) {
        this.addToSources(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasSources() {
    return this.sources != null && !this.sources.isEmpty();
  }
  
  public SourcesNested addNewSource() {
    return new SourcesNested(-1, null);
  }
  
  public SourcesNested addNewSourceLike(V1VolumeProjection item) {
    return new SourcesNested(-1, item);
  }
  
  public SourcesNested setNewSourceLike(int index,V1VolumeProjection item) {
    return new SourcesNested(index, item);
  }
  
  public SourcesNested editSource(int index) {
    if (sources.size() <= index) throw new RuntimeException("Can't edit sources. Index exceeds size.");
    return setNewSourceLike(index, buildSource(index));
  }
  
  public SourcesNested editFirstSource() {
    if (sources.size() == 0) throw new RuntimeException("Can't edit first sources. The list is empty.");
    return setNewSourceLike(0, buildSource(0));
  }
  
  public 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 SourcesNested editMatchingSource(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1VolumeProjectionFluent> implements Nested{
    SourcesNested(int index,V1VolumeProjection item) {
      this.index = index;
      this.builder = new V1VolumeProjectionBuilder(this, item);
    }
    V1VolumeProjectionBuilder builder;
    int index;
    
    public N and() {
      return (N) V1ProjectedVolumeSourceFluent.this.setToSources(index,builder.build());
    }
    
    public N endSource() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy