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

io.fabric8.knative.internal.networking.v1alpha1.HTTPIngressRuleValueFluent Maven / Gradle / Ivy

package io.fabric8.knative.internal.networking.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 java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;

 /**
  * Generated
  */
  @SuppressWarnings(value = "unchecked")
  public class HTTPIngressRuleValueFluent> extends BaseFluent{
  public HTTPIngressRuleValueFluent() {
  }
  public HTTPIngressRuleValueFluent(HTTPIngressRuleValue instance) {
    instance = (instance != null ? instance : new HTTPIngressRuleValue());

    if (instance != null) {
      this.withPaths(instance.getPaths());
      this.withPaths(instance.getPaths());
    }
  }
  private ArrayList paths = new ArrayList();
  public A addToPaths(int index,HTTPIngressPath item) {
    if (this.paths == null) {this.paths = new ArrayList();}
    HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);
    if (index < 0 || index >= paths.size()) { _visitables.get("paths").add(builder); paths.add(builder); } else { _visitables.get("paths").add(index, builder); paths.add(index, builder);}
    return (A)this;
  }
  public A setToPaths(int index,HTTPIngressPath item) {
    if (this.paths == null) {this.paths = new ArrayList();}
    HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);
    if (index < 0 || index >= paths.size()) { _visitables.get("paths").add(builder); paths.add(builder); } else { _visitables.get("paths").set(index, builder); paths.set(index, builder);}
    return (A)this;
  }
  public A addToPaths(io.fabric8.knative.internal.networking.v1alpha1.HTTPIngressPath... items) {
    if (this.paths == null) {this.paths = new ArrayList();}
    for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.get("paths").add(builder);this.paths.add(builder);} return (A)this;
  }
  public A addAllToPaths(Collection items) {
    if (this.paths == null) {this.paths = new ArrayList();}
    for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.get("paths").add(builder);this.paths.add(builder);} return (A)this;
  }
  public A removeFromPaths(io.fabric8.knative.internal.networking.v1alpha1.HTTPIngressPath... items) {
    if (this.paths == null) return (A)this;
    for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.get("paths").remove(builder); this.paths.remove(builder);} return (A)this;
  }
  public A removeAllFromPaths(Collection items) {
    if (this.paths == null) return (A)this;
    for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.get("paths").remove(builder); this.paths.remove(builder);} return (A)this;
  }
  public A removeMatchingFromPaths(Predicate predicate) {
    if (paths == null) return (A) this;
    final Iterator each = paths.iterator();
    final List visitables = _visitables.get("paths");
    while (each.hasNext()) {
      HTTPIngressPathBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  public List buildPaths() {
    return paths != null ? build(paths) : null;
  }
  public HTTPIngressPath buildPath(int index) {
    return this.paths.get(index).build();
  }
  public HTTPIngressPath buildFirstPath() {
    return this.paths.get(0).build();
  }
  public HTTPIngressPath buildLastPath() {
    return this.paths.get(paths.size() - 1).build();
  }
  public HTTPIngressPath buildMatchingPath(Predicate predicate) {
    for (HTTPIngressPathBuilder item: paths) { if(predicate.test(item)){ return item.build();} } return null;
  }
  public boolean hasMatchingPath(Predicate predicate) {
    for (HTTPIngressPathBuilder item: paths) { if(predicate.test(item)){ return true;} } return false;
  }
  public A withPaths(List paths) {
    if (this.paths != null) { _visitables.get("paths").clear();}
    if (paths != null) {this.paths = new ArrayList(); for (HTTPIngressPath item : paths){this.addToPaths(item);}} else { this.paths = null;} return (A) this;
  }
  public A withPaths(io.fabric8.knative.internal.networking.v1alpha1.HTTPIngressPath... paths) {
    if (this.paths != null) {this.paths.clear(); _visitables.remove("paths"); }
    if (paths != null) {for (HTTPIngressPath item :paths){ this.addToPaths(item);}} return (A) this;
  }
  public boolean hasPaths() {
    return paths != null && !paths.isEmpty();
  }
  public PathsNested addNewPath() {
    return new PathsNested(-1, null);
  }
  public PathsNested addNewPathLike(HTTPIngressPath item) {
    return new PathsNested(-1, item);
  }
  public PathsNested setNewPathLike(int index,HTTPIngressPath item) {
    return new PathsNested(index, item);
  }
  public PathsNested editPath(int index) {
    if (paths.size() <= index) throw new RuntimeException("Can't edit paths. Index exceeds size.");
    return setNewPathLike(index, buildPath(index));
  }
  public PathsNested editFirstPath() {
    if (paths.size() == 0) throw new RuntimeException("Can't edit first paths. The list is empty.");
    return setNewPathLike(0, buildPath(0));
  }
  public PathsNested editLastPath() {
    int index = paths.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last paths. The list is empty.");
    return setNewPathLike(index, buildPath(index));
  }
  public PathsNested editMatchingPath(Predicate predicate) {
    int index = -1;
    for (int i=0;i extends HTTPIngressPathFluent> implements Nested{
    PathsNested(int index,HTTPIngressPath item) {
      this.index = index;
      this.builder = new HTTPIngressPathBuilder(this, item);
    }
    HTTPIngressPathBuilder builder;
    int index;
    public N and() {
      return (N) HTTPIngressRuleValueFluent.this.setToPaths(index,builder.build());
    }
    public N endPath() {
      return and();
    }
    
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy