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

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

The newest version!
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 V1APIGroupListFluent> extends BaseFluent{
  public V1APIGroupListFluent() {
  }
  
  public V1APIGroupListFluent(V1APIGroupList instance) {
    this.copyInstance(instance);
  }
  private String apiVersion;
  private ArrayList groups;
  private String kind;
  
  protected void copyInstance(V1APIGroupList instance) {
    instance = (instance != null ? instance : new V1APIGroupList());
    if (instance != null) {
          this.withApiVersion(instance.getApiVersion());
          this.withGroups(instance.getGroups());
          this.withKind(instance.getKind());
        }
  }
  
  public String getApiVersion() {
    return this.apiVersion;
  }
  
  public A withApiVersion(String apiVersion) {
    this.apiVersion = apiVersion;
    return (A) this;
  }
  
  public boolean hasApiVersion() {
    return this.apiVersion != null;
  }
  
  public A addToGroups(int index,V1APIGroup item) {
    if (this.groups == null) {this.groups = new ArrayList();}
    V1APIGroupBuilder builder = new V1APIGroupBuilder(item);
    if (index < 0 || index >= groups.size()) {
        _visitables.get("groups").add(builder);
        groups.add(builder);
    } else {
        _visitables.get("groups").add(builder);
        groups.add(index, builder);
    }
    return (A)this;
  }
  
  public A setToGroups(int index,V1APIGroup item) {
    if (this.groups == null) {this.groups = new ArrayList();}
    V1APIGroupBuilder builder = new V1APIGroupBuilder(item);
    if (index < 0 || index >= groups.size()) {
        _visitables.get("groups").add(builder);
        groups.add(builder);
    } else {
        _visitables.get("groups").add(builder);
        groups.set(index, builder);
    }
    return (A)this;
  }
  
  public A addToGroups(io.kubernetes.client.openapi.models.V1APIGroup... items) {
    if (this.groups == null) {this.groups = new ArrayList();}
    for (V1APIGroup item : items) {V1APIGroupBuilder builder = new V1APIGroupBuilder(item);_visitables.get("groups").add(builder);this.groups.add(builder);} return (A)this;
  }
  
  public A addAllToGroups(Collection items) {
    if (this.groups == null) {this.groups = new ArrayList();}
    for (V1APIGroup item : items) {V1APIGroupBuilder builder = new V1APIGroupBuilder(item);_visitables.get("groups").add(builder);this.groups.add(builder);} return (A)this;
  }
  
  public A removeFromGroups(io.kubernetes.client.openapi.models.V1APIGroup... items) {
    if (this.groups == null) return (A)this;
    for (V1APIGroup item : items) {V1APIGroupBuilder builder = new V1APIGroupBuilder(item);_visitables.get("groups").remove(builder); this.groups.remove(builder);} return (A)this;
  }
  
  public A removeAllFromGroups(Collection items) {
    if (this.groups == null) return (A)this;
    for (V1APIGroup item : items) {V1APIGroupBuilder builder = new V1APIGroupBuilder(item);_visitables.get("groups").remove(builder); this.groups.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromGroups(Predicate predicate) {
    if (groups == null) return (A) this;
    final Iterator each = groups.iterator();
    final List visitables = _visitables.get("groups");
    while (each.hasNext()) {
      V1APIGroupBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildGroups() {
    return this.groups != null ? build(groups) : null;
  }
  
  public V1APIGroup buildGroup(int index) {
    return this.groups.get(index).build();
  }
  
  public V1APIGroup buildFirstGroup() {
    return this.groups.get(0).build();
  }
  
  public V1APIGroup buildLastGroup() {
    return this.groups.get(groups.size() - 1).build();
  }
  
  public V1APIGroup buildMatchingGroup(Predicate predicate) {
      for (V1APIGroupBuilder item : groups) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingGroup(Predicate predicate) {
      for (V1APIGroupBuilder item : groups) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withGroups(List groups) {
    if (this.groups != null) {
      this._visitables.get("groups").clear();
    }
    if (groups != null) {
        this.groups = new ArrayList();
        for (V1APIGroup item : groups) {
          this.addToGroups(item);
        }
    } else {
      this.groups = null;
    }
    return (A) this;
  }
  
  public A withGroups(io.kubernetes.client.openapi.models.V1APIGroup... groups) {
    if (this.groups != null) {
        this.groups.clear();
        _visitables.remove("groups");
    }
    if (groups != null) {
      for (V1APIGroup item : groups) {
        this.addToGroups(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasGroups() {
    return this.groups != null && !this.groups.isEmpty();
  }
  
  public GroupsNested addNewGroup() {
    return new GroupsNested(-1, null);
  }
  
  public GroupsNested addNewGroupLike(V1APIGroup item) {
    return new GroupsNested(-1, item);
  }
  
  public GroupsNested setNewGroupLike(int index,V1APIGroup item) {
    return new GroupsNested(index, item);
  }
  
  public GroupsNested editGroup(int index) {
    if (groups.size() <= index) throw new RuntimeException("Can't edit groups. Index exceeds size.");
    return setNewGroupLike(index, buildGroup(index));
  }
  
  public GroupsNested editFirstGroup() {
    if (groups.size() == 0) throw new RuntimeException("Can't edit first groups. The list is empty.");
    return setNewGroupLike(0, buildGroup(0));
  }
  
  public GroupsNested editLastGroup() {
    int index = groups.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last groups. The list is empty.");
    return setNewGroupLike(index, buildGroup(index));
  }
  
  public GroupsNested editMatchingGroup(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends V1APIGroupFluent> implements Nested{
    GroupsNested(int index,V1APIGroup item) {
      this.index = index;
      this.builder = new V1APIGroupBuilder(this, item);
    }
    V1APIGroupBuilder builder;
    int index;
    
    public N and() {
      return (N) V1APIGroupListFluent.this.setToGroups(index,builder.build());
    }
    
    public N endGroup() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy