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

io.kubernetes.client.openapi.models.V1alpha2StructuredResourceHandleFluent 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 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 V1alpha2StructuredResourceHandleFluent> extends BaseFluent{
  public V1alpha2StructuredResourceHandleFluent() {
  }
  
  public V1alpha2StructuredResourceHandleFluent(V1alpha2StructuredResourceHandle instance) {
    this.copyInstance(instance);
  }
  private String nodeName;
  private ArrayList results;
  private Object vendorClaimParameters;
  private Object vendorClassParameters;
  
  protected void copyInstance(V1alpha2StructuredResourceHandle instance) {
    instance = (instance != null ? instance : new V1alpha2StructuredResourceHandle());
    if (instance != null) {
          this.withNodeName(instance.getNodeName());
          this.withResults(instance.getResults());
          this.withVendorClaimParameters(instance.getVendorClaimParameters());
          this.withVendorClassParameters(instance.getVendorClassParameters());
        }
  }
  
  public String getNodeName() {
    return this.nodeName;
  }
  
  public A withNodeName(String nodeName) {
    this.nodeName = nodeName;
    return (A) this;
  }
  
  public boolean hasNodeName() {
    return this.nodeName != null;
  }
  
  public A addToResults(int index,V1alpha2DriverAllocationResult item) {
    if (this.results == null) {this.results = new ArrayList();}
    V1alpha2DriverAllocationResultBuilder builder = new V1alpha2DriverAllocationResultBuilder(item);
    if (index < 0 || index >= results.size()) { _visitables.get("results").add(builder); results.add(builder); } else { _visitables.get("results").add(index, builder); results.add(index, builder);}
    return (A)this;
  }
  
  public A setToResults(int index,V1alpha2DriverAllocationResult item) {
    if (this.results == null) {this.results = new ArrayList();}
    V1alpha2DriverAllocationResultBuilder builder = new V1alpha2DriverAllocationResultBuilder(item);
    if (index < 0 || index >= results.size()) { _visitables.get("results").add(builder); results.add(builder); } else { _visitables.get("results").set(index, builder); results.set(index, builder);}
    return (A)this;
  }
  
  public A addToResults(io.kubernetes.client.openapi.models.V1alpha2DriverAllocationResult... items) {
    if (this.results == null) {this.results = new ArrayList();}
    for (V1alpha2DriverAllocationResult item : items) {V1alpha2DriverAllocationResultBuilder builder = new V1alpha2DriverAllocationResultBuilder(item);_visitables.get("results").add(builder);this.results.add(builder);} return (A)this;
  }
  
  public A addAllToResults(Collection items) {
    if (this.results == null) {this.results = new ArrayList();}
    for (V1alpha2DriverAllocationResult item : items) {V1alpha2DriverAllocationResultBuilder builder = new V1alpha2DriverAllocationResultBuilder(item);_visitables.get("results").add(builder);this.results.add(builder);} return (A)this;
  }
  
  public A removeFromResults(io.kubernetes.client.openapi.models.V1alpha2DriverAllocationResult... items) {
    if (this.results == null) return (A)this;
    for (V1alpha2DriverAllocationResult item : items) {V1alpha2DriverAllocationResultBuilder builder = new V1alpha2DriverAllocationResultBuilder(item);_visitables.get("results").remove(builder); this.results.remove(builder);} return (A)this;
  }
  
  public A removeAllFromResults(Collection items) {
    if (this.results == null) return (A)this;
    for (V1alpha2DriverAllocationResult item : items) {V1alpha2DriverAllocationResultBuilder builder = new V1alpha2DriverAllocationResultBuilder(item);_visitables.get("results").remove(builder); this.results.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromResults(Predicate predicate) {
    if (results == null) return (A) this;
    final Iterator each = results.iterator();
    final List visitables = _visitables.get("results");
    while (each.hasNext()) {
      V1alpha2DriverAllocationResultBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildResults() {
    return this.results != null ? build(results) : null;
  }
  
  public V1alpha2DriverAllocationResult buildResult(int index) {
    return this.results.get(index).build();
  }
  
  public V1alpha2DriverAllocationResult buildFirstResult() {
    return this.results.get(0).build();
  }
  
  public V1alpha2DriverAllocationResult buildLastResult() {
    return this.results.get(results.size() - 1).build();
  }
  
  public V1alpha2DriverAllocationResult buildMatchingResult(Predicate predicate) {
      for (V1alpha2DriverAllocationResultBuilder item : results) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingResult(Predicate predicate) {
      for (V1alpha2DriverAllocationResultBuilder item : results) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withResults(List results) {
    if (this.results != null) {
      this._visitables.get("results").clear();
    }
    if (results != null) {
        this.results = new ArrayList();
        for (V1alpha2DriverAllocationResult item : results) {
          this.addToResults(item);
        }
    } else {
      this.results = null;
    }
    return (A) this;
  }
  
  public A withResults(io.kubernetes.client.openapi.models.V1alpha2DriverAllocationResult... results) {
    if (this.results != null) {
        this.results.clear();
        _visitables.remove("results");
    }
    if (results != null) {
      for (V1alpha2DriverAllocationResult item : results) {
        this.addToResults(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasResults() {
    return this.results != null && !this.results.isEmpty();
  }
  
  public ResultsNested addNewResult() {
    return new ResultsNested(-1, null);
  }
  
  public ResultsNested addNewResultLike(V1alpha2DriverAllocationResult item) {
    return new ResultsNested(-1, item);
  }
  
  public ResultsNested setNewResultLike(int index,V1alpha2DriverAllocationResult item) {
    return new ResultsNested(index, item);
  }
  
  public ResultsNested editResult(int index) {
    if (results.size() <= index) throw new RuntimeException("Can't edit results. Index exceeds size.");
    return setNewResultLike(index, buildResult(index));
  }
  
  public ResultsNested editFirstResult() {
    if (results.size() == 0) throw new RuntimeException("Can't edit first results. The list is empty.");
    return setNewResultLike(0, buildResult(0));
  }
  
  public ResultsNested editLastResult() {
    int index = results.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last results. The list is empty.");
    return setNewResultLike(index, buildResult(index));
  }
  
  public ResultsNested editMatchingResult(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1alpha2DriverAllocationResultFluent> implements Nested{
    ResultsNested(int index,V1alpha2DriverAllocationResult item) {
      this.index = index;
      this.builder = new V1alpha2DriverAllocationResultBuilder(this, item);
    }
    V1alpha2DriverAllocationResultBuilder builder;
    int index;
    
    public N and() {
      return (N) V1alpha2StructuredResourceHandleFluent.this.setToResults(index,builder.build());
    }
    
    public N endResult() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy