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

io.fabric8.knative.flows.v1.ParallelSpecFluentImpl 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 java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import io.fabric8.knative.messaging.v1.ChannelTemplateSpecBuilder;
import java.lang.Integer;
import io.fabric8.knative.messaging.v1.ChannelTemplateSpecFluentImpl;
import io.fabric8.knative.internal.pkg.apis.duck.v1.DestinationBuilder;
import java.util.Collection;
import java.lang.Object;
import io.fabric8.knative.internal.pkg.apis.duck.v1.DestinationFluentImpl;

 /**
  * Generated
  */
  @SuppressWarnings(value = "unchecked")
  public class ParallelSpecFluentImpl> extends BaseFluent implements ParallelSpecFluent{
  public ParallelSpecFluentImpl() {
  }
  public ParallelSpecFluentImpl(ParallelSpec instance) {
    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(Integer index,ParallelBranch item) {
    if (this.branches == null) {this.branches = new ArrayList();}
    ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").add(index >= 0 ? index : _visitables.get("branches").size(), builder);this.branches.add(index >= 0 ? index : branches.size(), builder); return (A)this;
  }
  public A setToBranches(Integer index,ParallelBranch item) {
    if (this.branches == null) {this.branches = new ArrayList();}
    ParallelBranchBuilder builder = new ParallelBranchBuilder(item);
    if (index < 0 || index >= _visitables.get("branches").size()) { _visitables.get("branches").add(builder); } else { _visitables.get("branches").set(index, builder);}
    if (index < 0 || index >= branches.size()) { branches.add(builder); } else { 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) {
    for (ParallelBranch item : items) {ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").remove(builder);if (this.branches != null) {this.branches.remove(builder);}} return (A)this;
  }
  public A removeAllFromBranches(Collection items) {
    for (ParallelBranch item : items) {ParallelBranchBuilder builder = new ParallelBranchBuilder(item);_visitables.get("branches").remove(builder);if (this.branches != null) {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;
  }
  
  /**
   * This method has been deprecated, please use method buildBranches instead.
   * @return The buildable object.
   */
  @Deprecated
  public List getBranches() {
    return branches != null ? build(branches) : null;
  }
  public List buildBranches() {
    return branches != null ? build(branches) : null;
  }
  public ParallelBranch buildBranch(Integer 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").removeAll(this.branches);}
    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();}
    if (branches != null) {for (ParallelBranch item :branches){ this.addToBranches(item);}} return (A) this;
  }
  public Boolean hasBranches() {
    return branches != null && !branches.isEmpty();
  }
  public ParallelSpecFluent.BranchesNested addNewBranch() {
    return new ParallelSpecFluentImpl.BranchesNestedImpl();
  }
  public ParallelSpecFluent.BranchesNested addNewBranchLike(ParallelBranch item) {
    return new ParallelSpecFluentImpl.BranchesNestedImpl(-1, item);
  }
  public ParallelSpecFluent.BranchesNested setNewBranchLike(Integer index,ParallelBranch item) {
    return new ParallelSpecFluentImpl.BranchesNestedImpl(index, item);
  }
  public ParallelSpecFluent.BranchesNested editBranch(Integer index) {
    if (branches.size() <= index) throw new RuntimeException("Can't edit branches. Index exceeds size.");
    return setNewBranchLike(index, buildBranch(index));
  }
  public ParallelSpecFluent.BranchesNested editFirstBranch() {
    if (branches.size() == 0) throw new RuntimeException("Can't edit first branches. The list is empty.");
    return setNewBranchLike(0, buildBranch(0));
  }
  public ParallelSpecFluent.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 ParallelSpecFluent.BranchesNested editMatchingBranch(Predicate predicate) {
    int index = -1;
    for (int i=0;i withNewChannelTemplate() {
    return new ParallelSpecFluentImpl.ChannelTemplateNestedImpl();
  }
  public ParallelSpecFluent.ChannelTemplateNested withNewChannelTemplateLike(ChannelTemplateSpec item) {
    return new ParallelSpecFluentImpl.ChannelTemplateNestedImpl(item);
  }
  public ParallelSpecFluent.ChannelTemplateNested editChannelTemplate() {
    return withNewChannelTemplateLike(getChannelTemplate());
  }
  public ParallelSpecFluent.ChannelTemplateNested editOrNewChannelTemplate() {
    return withNewChannelTemplateLike(getChannelTemplate() != null ? getChannelTemplate(): new ChannelTemplateSpecBuilder().build());
  }
  public ParallelSpecFluent.ChannelTemplateNested editOrNewChannelTemplateLike(ChannelTemplateSpec item) {
    return withNewChannelTemplateLike(getChannelTemplate() != null ? getChannelTemplate(): item);
  }
  
  /**
   * This method has been deprecated, please use method buildReply instead.
   * @return The buildable object.
   */
  @Deprecated
  public Destination getReply() {
    return this.reply!=null ?this.reply.build():null;
  }
  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 ParallelSpecFluent.ReplyNested withNewReply() {
    return new ParallelSpecFluentImpl.ReplyNestedImpl();
  }
  public ParallelSpecFluent.ReplyNested withNewReplyLike(Destination item) {
    return new ParallelSpecFluentImpl.ReplyNestedImpl(item);
  }
  public ParallelSpecFluent.ReplyNested editReply() {
    return withNewReplyLike(getReply());
  }
  public ParallelSpecFluent.ReplyNested editOrNewReply() {
    return withNewReplyLike(getReply() != null ? getReply(): new DestinationBuilder().build());
  }
  public ParallelSpecFluent.ReplyNested editOrNewReplyLike(Destination item) {
    return withNewReplyLike(getReply() != null ? getReply(): item);
  }
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    ParallelSpecFluentImpl that = (ParallelSpecFluentImpl) o;
    if (branches != null ? !branches.equals(that.branches) :that.branches != null) return false;
    if (channelTemplate != null ? !channelTemplate.equals(that.channelTemplate) :that.channelTemplate != null) return false;
    if (reply != null ? !reply.equals(that.reply) :that.reply != null) 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();
  }
  class BranchesNestedImpl extends ParallelBranchFluentImpl> implements ParallelSpecFluent.BranchesNested,Nested{
    BranchesNestedImpl(Integer index,ParallelBranch item) {
      this.index = index;
      this.builder = new ParallelBranchBuilder(this, item);
    }
    BranchesNestedImpl() {
      this.index = -1;
      this.builder = new ParallelBranchBuilder(this);
    }
    ParallelBranchBuilder builder;
    Integer index;
    public N and() {
      return (N) ParallelSpecFluentImpl.this.setToBranches(index,builder.build());
    }
    public N endBranch() {
      return and();
    }
    
  }
  class ChannelTemplateNestedImpl extends ChannelTemplateSpecFluentImpl> implements ParallelSpecFluent.ChannelTemplateNested,Nested{
    ChannelTemplateNestedImpl(ChannelTemplateSpec item) {
      this.builder = new ChannelTemplateSpecBuilder(this, item);
    }
    ChannelTemplateNestedImpl() {
      this.builder = new ChannelTemplateSpecBuilder(this);
    }
    ChannelTemplateSpecBuilder builder;
    public N and() {
      return (N) ParallelSpecFluentImpl.this.withChannelTemplate(builder.build());
    }
    public N endChannelTemplate() {
      return and();
    }
    
  }
  class ReplyNestedImpl extends DestinationFluentImpl> implements ParallelSpecFluent.ReplyNested,Nested{
    ReplyNestedImpl(Destination item) {
      this.builder = new DestinationBuilder(this, item);
    }
    ReplyNestedImpl() {
      this.builder = new DestinationBuilder(this);
    }
    DestinationBuilder builder;
    public N and() {
      return (N) ParallelSpecFluentImpl.this.withReply(builder.build());
    }
    public N endReply() {
      return and();
    }
    
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy