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

io.fabric8.knative.flows.v1.ParallelSpecFluent Maven / Gradle / Ivy

package io.fabric8.knative.flows.v1;

import io.fabric8.knative.internal.pkg.apis.duck.v1.Destination;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.fabric8.knative.messaging.v1.ChannelTemplateSpec;
import java.lang.String;
import java.util.function.Predicate;
import io.fabric8.knative.internal.pkg.apis.duck.v1.DestinationFluent;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import io.fabric8.knative.messaging.v1.ChannelTemplateSpecBuilder;
import io.fabric8.knative.messaging.v1.ChannelTemplateSpecFluent;
import io.fabric8.knative.internal.pkg.apis.duck.v1.DestinationBuilder;
import java.util.Collection;
import java.lang.Object;

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

    if (instance != null) {
      this.withBranches(instance.getBranches());
      this.withChannelTemplate(instance.getChannelTemplate());
      this.withReply(instance.getReply());
      this.withBranches(instance.getBranches());
      this.withChannelTemplate(instance.getChannelTemplate());
      this.withReply(instance.getReply());
    }
  }
  private ArrayList branches = new ArrayList();
  private ChannelTemplateSpecBuilder channelTemplate;
  private DestinationBuilder reply;
  public A addToBranches(int index,ParallelBranch item) {
    if (this.branches == null) {this.branches = new ArrayList();}
    ParallelBranchBuilder builder = new ParallelBranchBuilder(item);
    if (index < 0 || index >= branches.size()) { _visitables.get("branches").add(builder); branches.add(builder); } else { _visitables.get("branches").add(index, builder); branches.add(index, builder);}
    return (A)this;
  }
  public A setToBranches(int index,ParallelBranch item) {
    if (this.branches == null) {this.branches = new ArrayList();}
    ParallelBranchBuilder builder = new ParallelBranchBuilder(item);
    if (index < 0 || index >= branches.size()) { _visitables.get("branches").add(builder); branches.add(builder); } else { _visitables.get("branches").set(index, builder); branches.set(index, builder);}
    return (A)this;
  }
  public A addToBranches(io.fabric8.knative.flows.v1.ParallelBranch... items) {
    if (this.branches == null) {this.branches = new ArrayList();}
    for (ParallelBranch item : items) {ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").add(builder);this.branches.add(builder);} return (A)this;
  }
  public A addAllToBranches(Collection items) {
    if (this.branches == null) {this.branches = new ArrayList();}
    for (ParallelBranch item : items) {ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").add(builder);this.branches.add(builder);} return (A)this;
  }
  public A removeFromBranches(io.fabric8.knative.flows.v1.ParallelBranch... items) {
    if (this.branches == null) return (A)this;
    for (ParallelBranch item : items) {ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").remove(builder); this.branches.remove(builder);} return (A)this;
  }
  public A removeAllFromBranches(Collection items) {
    if (this.branches == null) return (A)this;
    for (ParallelBranch item : items) {ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").remove(builder); this.branches.remove(builder);} return (A)this;
  }
  public A removeMatchingFromBranches(Predicate predicate) {
    if (branches == null) return (A) this;
    final Iterator each = branches.iterator();
    final List visitables = _visitables.get("branches");
    while (each.hasNext()) {
      ParallelBranchBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  public List buildBranches() {
    return branches != null ? build(branches) : null;
  }
  public ParallelBranch buildBranch(int index) {
    return this.branches.get(index).build();
  }
  public ParallelBranch buildFirstBranch() {
    return this.branches.get(0).build();
  }
  public ParallelBranch buildLastBranch() {
    return this.branches.get(branches.size() - 1).build();
  }
  public ParallelBranch buildMatchingBranch(Predicate predicate) {
    for (ParallelBranchBuilder item: branches) { if(predicate.test(item)){ return item.build();} } return null;
  }
  public boolean hasMatchingBranch(Predicate predicate) {
    for (ParallelBranchBuilder item: branches) { if(predicate.test(item)){ return true;} } return false;
  }
  public A withBranches(List branches) {
    if (this.branches != null) { _visitables.get("branches").clear();}
    if (branches != null) {this.branches = new ArrayList(); for (ParallelBranch item : branches){this.addToBranches(item);}} else { this.branches = null;} return (A) this;
  }
  public A withBranches(io.fabric8.knative.flows.v1.ParallelBranch... branches) {
    if (this.branches != null) {this.branches.clear(); _visitables.remove("branches"); }
    if (branches != null) {for (ParallelBranch item :branches){ this.addToBranches(item);}} return (A) this;
  }
  public boolean hasBranches() {
    return branches != null && !branches.isEmpty();
  }
  public BranchesNested addNewBranch() {
    return new BranchesNested(-1, null);
  }
  public BranchesNested addNewBranchLike(ParallelBranch item) {
    return new BranchesNested(-1, item);
  }
  public BranchesNested setNewBranchLike(int index,ParallelBranch item) {
    return new BranchesNested(index, item);
  }
  public BranchesNested editBranch(int index) {
    if (branches.size() <= index) throw new RuntimeException("Can't edit branches. Index exceeds size.");
    return setNewBranchLike(index, buildBranch(index));
  }
  public BranchesNested editFirstBranch() {
    if (branches.size() == 0) throw new RuntimeException("Can't edit first branches. The list is empty.");
    return setNewBranchLike(0, buildBranch(0));
  }
  public BranchesNested editLastBranch() {
    int index = branches.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last branches. The list is empty.");
    return setNewBranchLike(index, buildBranch(index));
  }
  public BranchesNested editMatchingBranch(Predicate predicate) {
    int index = -1;
    for (int i=0;i withNewChannelTemplate() {
    return new ChannelTemplateNested(null);
  }
  public ChannelTemplateNested withNewChannelTemplateLike(ChannelTemplateSpec item) {
    return new ChannelTemplateNested(item);
  }
  public ChannelTemplateNested editChannelTemplate() {
    return withNewChannelTemplateLike(java.util.Optional.ofNullable(buildChannelTemplate()).orElse(null));
  }
  public ChannelTemplateNested editOrNewChannelTemplate() {
    return withNewChannelTemplateLike(java.util.Optional.ofNullable(buildChannelTemplate()).orElse(new ChannelTemplateSpecBuilder().build()));
  }
  public ChannelTemplateNested editOrNewChannelTemplateLike(ChannelTemplateSpec item) {
    return withNewChannelTemplateLike(java.util.Optional.ofNullable(buildChannelTemplate()).orElse(item));
  }
  public Destination buildReply() {
    return this.reply!=null ?this.reply.build():null;
  }
  public A withReply(Destination reply) {
    _visitables.get("reply").remove(this.reply);
    if (reply!=null){ this.reply= new DestinationBuilder(reply); _visitables.get("reply").add(this.reply);} else { this.reply = null; _visitables.get("reply").remove(this.reply); } return (A) this;
  }
  public boolean hasReply() {
    return this.reply != null;
  }
  public ReplyNested withNewReply() {
    return new ReplyNested(null);
  }
  public ReplyNested withNewReplyLike(Destination item) {
    return new ReplyNested(item);
  }
  public ReplyNested editReply() {
    return withNewReplyLike(java.util.Optional.ofNullable(buildReply()).orElse(null));
  }
  public ReplyNested editOrNewReply() {
    return withNewReplyLike(java.util.Optional.ofNullable(buildReply()).orElse(new DestinationBuilder().build()));
  }
  public ReplyNested editOrNewReplyLike(Destination item) {
    return withNewReplyLike(java.util.Optional.ofNullable(buildReply()).orElse(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;
    ParallelSpecFluent that = (ParallelSpecFluent) o;
    if (!java.util.Objects.equals(branches, that.branches)) return false;

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

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

    return true;
  }
  public int hashCode() {
    return java.util.Objects.hash(branches,  channelTemplate,  reply,  super.hashCode());
  }
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (branches != null && !branches.isEmpty()) { sb.append("branches:"); sb.append(branches + ","); }
    if (channelTemplate != null) { sb.append("channelTemplate:"); sb.append(channelTemplate + ","); }
    if (reply != null) { sb.append("reply:"); sb.append(reply); }
    sb.append("}");
    return sb.toString();
  }
  public class BranchesNested extends ParallelBranchFluent> implements Nested{
    BranchesNested(int index,ParallelBranch item) {
      this.index = index;
      this.builder = new ParallelBranchBuilder(this, item);
    }
    ParallelBranchBuilder builder;
    int index;
    public N and() {
      return (N) ParallelSpecFluent.this.setToBranches(index,builder.build());
    }
    public N endBranch() {
      return and();
    }
    
  }
  public class ChannelTemplateNested extends ChannelTemplateSpecFluent> implements Nested{
    ChannelTemplateNested(ChannelTemplateSpec item) {
      this.builder = new ChannelTemplateSpecBuilder(this, item);
    }
    ChannelTemplateSpecBuilder builder;
    public N and() {
      return (N) ParallelSpecFluent.this.withChannelTemplate(builder.build());
    }
    public N endChannelTemplate() {
      return and();
    }
    
  }
  public class ReplyNested extends DestinationFluent> implements Nested{
    ReplyNested(Destination item) {
      this.builder = new DestinationBuilder(this, item);
    }
    DestinationBuilder builder;
    public N and() {
      return (N) ParallelSpecFluent.this.withReply(builder.build());
    }
    public N endReply() {
      return and();
    }
    
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy