/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.debugger.streams.resolve.impl;

import com.intellij.debugger.streams.resolve.ResolvedStreamCall;
import com.intellij.debugger.streams.resolve.ResolvedStreamChain;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Vitaliy.Bibaev
 */
public class ResolvedStreamChainImpl implements ResolvedStreamChain {

  private final ResolvedStreamCall.Producer myProducer;
  private final ResolvedStreamCall.Terminator myTerminator;
  private final List<ResolvedStreamCall.Intermediate> myIntermediateCalls;

  public ResolvedStreamChainImpl(@NotNull ResolvedStreamCall.Producer producer,
                                 @NotNull ResolvedStreamCall.Terminator terminator,
                                 @NotNull List<ResolvedStreamCall.Intermediate> intermediates) {
    myProducer = producer;
    myTerminator = terminator;
    myIntermediateCalls = Collections.unmodifiableList(new ArrayList<>(intermediates));
  }

  @NotNull
  @Override
  public ResolvedStreamCall.Producer getProducer() {
    return myProducer;
  }

  @NotNull
  @Override
  public ResolvedStreamCall.Terminator getTerminator() {
    return myTerminator;
  }

  @NotNull
  @Override
  public List<ResolvedStreamCall.Intermediate> getIntermediateCalls() {
    return myIntermediateCalls;
  }
}

@@ -1956,11 +1956,1035 @@
 lls;%0A  %7D
+%0A%0A  public static class Builder %7B%0A    private ResolvedStreamCall.Producer myProducer;%0A    private ResolvedStreamCall.Terminator myTerminator;%0A    private List%3CResolvedStreamCall.Intermediate%3E myIntermediates = new ArrayList%3C%3E();%0A%0A    public Builder setProducer(@NotNull ResolvedStreamCall.Producer producer) %7B%0A      myProducer = producer;%0A      return this;%0A    %7D%0A%0A    public Builder addIntermediate(@NotNull ResolvedStreamCall.Intermediate intermediate) %7B%0A      myIntermediates.add(intermediate);%0A      return this;%0A    %7D%0A%0A    public Builder setTerminator(@NotNull ResolvedStreamCall.Terminator terminator) %7B%0A      myTerminator = terminator;%0A      return this;%0A    %7D%0A%0A    public ResolvedStreamChain build() %7B%0A      if (myProducer == null) %7B%0A        throw new IllegalStateException(%22producer not specified%22);%0A      %7D%0A%0A      if (myTerminator == null) %7B%0A        throw new IllegalStateException(%22terminator not specified%22);%0A      %7D%0A%0A      return new ResolvedStreamChainImpl(myProducer, myTerminator, myIntermediates);%0A    %7D%0A  %7D
 %0A%7D%0A

Add builder for the ResolvedStreamChainImpl