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

io.fabric8.tekton.triggers.v1alpha1.ClusterInterceptorListFluent Maven / Gradle / Ivy

package io.fabric8.tekton.triggers.v1alpha1;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.fabric8.kubernetes.api.model.ListMeta;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.lang.Long;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class ClusterInterceptorListFluent> extends BaseFluent{
  public ClusterInterceptorListFluent() {
  }
  
  public ClusterInterceptorListFluent(ClusterInterceptorList instance) {
    this.copyInstance(instance);
  }
  private String apiVersion;
  private ArrayList items = new ArrayList();
  private String kind;
  private ListMeta metadata;
  private Map additionalProperties;
  
  protected void copyInstance(ClusterInterceptorList instance) {
    instance = (instance != null ? instance : new ClusterInterceptorList());
    if (instance != null) {
          this.withApiVersion(instance.getApiVersion());
          this.withItems(instance.getItems());
          this.withKind(instance.getKind());
          this.withMetadata(instance.getMetadata());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  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,ClusterInterceptor item) {
    if (this.items == null) {this.items = new ArrayList();}
    ClusterInterceptorBuilder builder = new ClusterInterceptorBuilder(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,ClusterInterceptor item) {
    if (this.items == null) {this.items = new ArrayList();}
    ClusterInterceptorBuilder builder = new ClusterInterceptorBuilder(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.fabric8.tekton.triggers.v1alpha1.ClusterInterceptor... items) {
    if (this.items == null) {this.items = new ArrayList();}
    for (ClusterInterceptor item : items) {ClusterInterceptorBuilder builder = new ClusterInterceptorBuilder(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 (ClusterInterceptor item : items) {ClusterInterceptorBuilder builder = new ClusterInterceptorBuilder(item);_visitables.get("items").add(builder);this.items.add(builder);} return (A)this;
  }
  
  public A removeFromItems(io.fabric8.tekton.triggers.v1alpha1.ClusterInterceptor... items) {
    if (this.items == null) return (A)this;
    for (ClusterInterceptor item : items) {ClusterInterceptorBuilder builder = new ClusterInterceptorBuilder(item);_visitables.get("items").remove(builder); this.items.remove(builder);} return (A)this;
  }
  
  public A removeAllFromItems(Collection items) {
    if (this.items == null) return (A)this;
    for (ClusterInterceptor item : items) {ClusterInterceptorBuilder builder = new ClusterInterceptorBuilder(item);_visitables.get("items").remove(builder); 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()) {
      ClusterInterceptorBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildItems() {
    return this.items != null ? build(items) : null;
  }
  
  public ClusterInterceptor buildItem(int index) {
    return this.items.get(index).build();
  }
  
  public ClusterInterceptor buildFirstItem() {
    return this.items.get(0).build();
  }
  
  public ClusterInterceptor buildLastItem() {
    return this.items.get(items.size() - 1).build();
  }
  
  public ClusterInterceptor buildMatchingItem(Predicate predicate) {
      for (ClusterInterceptorBuilder item : items) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingItem(Predicate predicate) {
      for (ClusterInterceptorBuilder item : items) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withItems(List items) {
    if (this.items != null) {
      this._visitables.get("items").clear();
    }
    if (items != null) {
        this.items = new ArrayList();
        for (ClusterInterceptor item : items) {
          this.addToItems(item);
        }
    } else {
      this.items = null;
    }
    return (A) this;
  }
  
  public A withItems(io.fabric8.tekton.triggers.v1alpha1.ClusterInterceptor... items) {
    if (this.items != null) {
        this.items.clear();
        _visitables.remove("items");
    }
    if (items != null) {
      for (ClusterInterceptor item : items) {
        this.addToItems(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasItems() {
    return this.items != null && !this.items.isEmpty();
  }
  
  public ItemsNested addNewItem() {
    return new ItemsNested(-1, null);
  }
  
  public ItemsNested addNewItemLike(ClusterInterceptor item) {
    return new ItemsNested(-1, item);
  }
  
  public ItemsNested setNewItemLike(int index,ClusterInterceptor item) {
    return new ItemsNested(index, item);
  }
  
  public ItemsNested editItem(int index) {
    if (items.size() <= index) throw new RuntimeException("Can't edit items. Index exceeds size.");
    return setNewItemLike(index, buildItem(index));
  }
  
  public ItemsNested editFirstItem() {
    if (items.size() == 0) throw new RuntimeException("Can't edit first items. The list is empty.");
    return setNewItemLike(0, buildItem(0));
  }
  
  public 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 ItemsNested editMatchingItem(Predicate predicate) {
    int index = -1;
    for (int i=0;i map) {
    if(this.additionalProperties == null && map != null) { this.additionalProperties = new LinkedHashMap(); }
    if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
  }
  
  public A removeFromAdditionalProperties(String key) {
    if(this.additionalProperties == null) { return (A) this; }
    if(key != null && this.additionalProperties != null) {this.additionalProperties.remove(key);} return (A)this;
  }
  
  public A removeFromAdditionalProperties(Map map) {
    if(this.additionalProperties == null) { return (A) this; }
    if(map != null) { for(Object key : map.keySet()) {if (this.additionalProperties != null){this.additionalProperties.remove(key);}}} return (A)this;
  }
  
  public Map getAdditionalProperties() {
    return this.additionalProperties;
  }
  
  public A withAdditionalProperties(Map additionalProperties) {
    if (additionalProperties == null) {
      this.additionalProperties = null;
    } else {
      this.additionalProperties = new LinkedHashMap(additionalProperties);
    }
    return (A) this;
  }
  
  public boolean hasAdditionalProperties() {
    return this.additionalProperties != null;
  }
  
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    ClusterInterceptorListFluent that = (ClusterInterceptorListFluent) 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;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(apiVersion,  items,  kind,  metadata,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (apiVersion != null) { sb.append("apiVersion:"); sb.append(apiVersion + ","); }
    if (items != null && !items.isEmpty()) { sb.append("items:"); sb.append(items + ","); }
    if (kind != null) { sb.append("kind:"); sb.append(kind + ","); }
    if (metadata != null) { sb.append("metadata:"); sb.append(metadata + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class ItemsNested extends ClusterInterceptorFluent> implements Nested{
    ItemsNested(int index,ClusterInterceptor item) {
      this.index = index;
      this.builder = new ClusterInterceptorBuilder(this, item);
    }
    ClusterInterceptorBuilder builder;
    int index;
    
    public N and() {
      return (N) ClusterInterceptorListFluent.this.setToItems(index,builder.build());
    }
    
    public N endItem() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy