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

io.kubernetes.client.openapi.models.V1ServiceListFluentImpl 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.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.util.Collection;
import java.lang.Object;

 /**
  * Generated
  */
  @SuppressWarnings(value = "unchecked")
  public class V1ServiceListFluentImpl> extends BaseFluent implements V1ServiceListFluent{
  public V1ServiceListFluentImpl() {
  }
  public V1ServiceListFluentImpl(V1ServiceList instance) {
    if (instance != null) {
      this.withApiVersion(instance.getApiVersion());
      this.withItems(instance.getItems());
      this.withKind(instance.getKind());
      this.withMetadata(instance.getMetadata());
    }
  }
  private String apiVersion;
  private ArrayList items;
  private String kind;
  private V1ListMetaBuilder metadata;
  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 addToItems(int index,V1Service item) {
    if (this.items == null) {this.items = new ArrayList();}
    V1ServiceBuilder builder = new V1ServiceBuilder(item);
    if (index < 0 || index >= items.size()) { _visitables.get("items").add(builder); items.add(builder); } else { _visitables.get("items").add(index, builder); items.add(index, builder);}
    return (A)this;
  }
  public A setToItems(int index,V1Service item) {
    if (this.items == null) {this.items = new ArrayList();}
    V1ServiceBuilder builder = new V1ServiceBuilder(item);
    if (index < 0 || index >= items.size()) { _visitables.get("items").add(builder); items.add(builder); } else { _visitables.get("items").set(index, builder); items.set(index, builder);}
    return (A)this;
  }
  public A addToItems(io.kubernetes.client.openapi.models.V1Service... items) {
    if (this.items == null) {this.items = new ArrayList();}
    for (V1Service item : items) {V1ServiceBuilder builder = new V1ServiceBuilder(item);_visitables.get("items").add(builder);this.items.add(builder);} return (A)this;
  }
  public A addAllToItems(Collection items) {
    if (this.items == null) {this.items = new ArrayList();}
    for (V1Service item : items) {V1ServiceBuilder builder = new V1ServiceBuilder(item);_visitables.get("items").add(builder);this.items.add(builder);} return (A)this;
  }
  public A removeFromItems(io.kubernetes.client.openapi.models.V1Service... items) {
    for (V1Service item : items) {V1ServiceBuilder builder = new V1ServiceBuilder(item);_visitables.get("items").remove(builder);if (this.items != null) {this.items.remove(builder);}} return (A)this;
  }
  public A removeAllFromItems(Collection items) {
    for (V1Service item : items) {V1ServiceBuilder builder = new V1ServiceBuilder(item);_visitables.get("items").remove(builder);if (this.items != null) {this.items.remove(builder);}} return (A)this;
  }
  public A removeMatchingFromItems(Predicate predicate) {
    if (items == null) return (A) this;
    final Iterator each = items.iterator();
    final List visitables = _visitables.get("items");
    while (each.hasNext()) {
      V1ServiceBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  /**
   * This method has been deprecated, please use method buildItems instead.
   * @return The buildable object.
   */
  @Deprecated
  public List getItems() {
    return items != null ? build(items) : null;
  }
  public List buildItems() {
    return items != null ? build(items) : null;
  }
  public V1Service buildItem(int index) {
    return this.items.get(index).build();
  }
  public V1Service buildFirstItem() {
    return this.items.get(0).build();
  }
  public V1Service buildLastItem() {
    return this.items.get(items.size() - 1).build();
  }
  public V1Service buildMatchingItem(Predicate predicate) {
    for (V1ServiceBuilder item: items) { if(predicate.test(item)){ return item.build();} } return null;
  }
  public Boolean hasMatchingItem(Predicate predicate) {
    for (V1ServiceBuilder item: items) { if(predicate.test(item)){ return true;} } return false;
  }
  public A withItems(List items) {
    if (this.items != null) { _visitables.get("items").clear();}
    if (items != null) {this.items = new ArrayList(); for (V1Service item : items){this.addToItems(item);}} else { this.items = null;} return (A) this;
  }
  public A withItems(io.kubernetes.client.openapi.models.V1Service... items) {
    if (this.items != null) {this.items.clear(); _visitables.remove("items"); }
    if (items != null) {for (V1Service item :items){ this.addToItems(item);}} return (A) this;
  }
  public Boolean hasItems() {
    return items != null && !items.isEmpty();
  }
  public V1ServiceListFluentImpl.ItemsNested addNewItem() {
    return new V1ServiceListFluentImpl.ItemsNestedImpl();
  }
  public V1ServiceListFluentImpl.ItemsNested addNewItemLike(V1Service item) {
    return new V1ServiceListFluentImpl.ItemsNestedImpl(-1, item);
  }
  public V1ServiceListFluentImpl.ItemsNested setNewItemLike(int index,V1Service item) {
    return new V1ServiceListFluentImpl.ItemsNestedImpl(index, item);
  }
  public V1ServiceListFluentImpl.ItemsNested editItem(int index) {
    if (items.size() <= index) throw new RuntimeException("Can't edit items. Index exceeds size.");
    return setNewItemLike(index, buildItem(index));
  }
  public V1ServiceListFluentImpl.ItemsNested editFirstItem() {
    if (items.size() == 0) throw new RuntimeException("Can't edit first items. The list is empty.");
    return setNewItemLike(0, buildItem(0));
  }
  public V1ServiceListFluentImpl.ItemsNested editLastItem() {
    int index = items.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last items. The list is empty.");
    return setNewItemLike(index, buildItem(index));
  }
  public V1ServiceListFluentImpl.ItemsNested editMatchingItem(Predicate predicate) {
    int index = -1;
    for (int i=0;i withNewMetadata() {
    return new V1ServiceListFluentImpl.MetadataNestedImpl();
  }
  public V1ServiceListFluentImpl.MetadataNested withNewMetadataLike(V1ListMeta item) {
    return new V1ServiceListFluentImpl.MetadataNestedImpl(item);
  }
  public V1ServiceListFluentImpl.MetadataNested editMetadata() {
    return withNewMetadataLike(getMetadata());
  }
  public V1ServiceListFluentImpl.MetadataNested editOrNewMetadata() {
    return withNewMetadataLike(getMetadata() != null ? getMetadata(): new V1ListMetaBuilder().build());
  }
  public V1ServiceListFluentImpl.MetadataNested editOrNewMetadataLike(V1ListMeta item) {
    return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
  }
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    V1ServiceListFluentImpl that = (V1ServiceListFluentImpl) o;
    if (!java.util.Objects.equals(apiVersion, that.apiVersion)) return false;

    if (!java.util.Objects.equals(items, that.items)) return false;

    if (!java.util.Objects.equals(kind, that.kind)) return false;

    if (!java.util.Objects.equals(metadata, that.metadata)) return false;

    return true;
  }
  public int hashCode() {
    return java.util.Objects.hash(apiVersion,  items,  kind,  metadata,  super.hashCode());
  }
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (apiVersion != null) { sb.append("apiVersion:"); sb.append(apiVersion + ","); }
    if (items != null) { sb.append("items:"); sb.append(items + ","); }
    if (kind != null) { sb.append("kind:"); sb.append(kind + ","); }
    if (metadata != null) { sb.append("metadata:"); sb.append(metadata); }
    sb.append("}");
    return sb.toString();
  }
  class ItemsNestedImpl extends V1ServiceFluentImpl> implements V1ServiceListFluentImpl.ItemsNested,Nested{
    ItemsNestedImpl(int index,V1Service item) {
      this.index = index;
      this.builder = new V1ServiceBuilder(this, item);
    }
    ItemsNestedImpl() {
      this.index = -1;
      this.builder = new V1ServiceBuilder(this);
    }
    V1ServiceBuilder builder;
    int index;
    public N and() {
      return (N) V1ServiceListFluentImpl.this.setToItems(index,builder.build());
    }
    public N endItem() {
      return and();
    }
    
  }
  class MetadataNestedImpl extends V1ListMetaFluentImpl> implements V1ServiceListFluentImpl.MetadataNested,Nested{
    MetadataNestedImpl(V1ListMeta item) {
      this.builder = new V1ListMetaBuilder(this, item);
    }
    MetadataNestedImpl() {
      this.builder = new V1ListMetaBuilder(this);
    }
    V1ListMetaBuilder builder;
    public N and() {
      return (N) V1ServiceListFluentImpl.this.withMetadata(builder.build());
    }
    public N endMetadata() {
      return and();
    }
    
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy