/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.beam.sdk.values;

import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.transforms.AppliedPTransform;
import org.apache.beam.sdk.transforms.PTransform;

/**
 * A {@link POutputValueBase} is the abstract base class of
 * {@code PTransform} outputs.
 *
 * <p>A {@link PValueBase} that adds tracking of its producing
 * {@link AppliedPTransform}.
 *
 * <p>For internal use.
 */
public abstract class POutputValueBase implements POutput {

  private final Pipeline pipeline;

  protected POutputValueBase(Pipeline pipeline) {
    this.pipeline = pipeline;
  }

  /**
   * No-arg constructor for Java serialization only.
   * The resulting {@link POutputValueBase} is unlikely to be
   * valid.
   */
  protected POutputValueBase() {
    pipeline = null;
  }

  @Override
  public Pipeline getPipeline() {
    return pipeline;
  }

  /**
   * Returns the {@link AppliedPTransform} that this {@link POutputValueBase}
   * is an output of.
   *
   * <p>For internal use only.
   */
  public AppliedPTransform<?, ?, ?> getProducingTransformInternal() {
    return producingTransform;
  }

  /**
   * Records that this {@link POutputValueBase} is an output with the
   * given name of the given {@link AppliedPTransform}.
   *
   * <p>To be invoked only by {@link POutput#recordAsOutput}
   * implementations.  Not to be invoked directly by user code.
   */
  @Override
  public void recordAsOutput(AppliedPTransform<?, ?, ?> transform) {
    if (producingTransform != null) {
      // Already used this POutput as a PTransform output.  This can
      // happen if the POutput is an output of a transform within a
      // composite transform, and is also the result of the composite.
      // We want to record the "immediate" atomic transform producing
      // this output, and ignore all later composite transforms that
      // also produce this output.
      //
      // Pipeline.applyInternal() uses !hasProducingTransform() to
      // avoid calling this operation redundantly, but
      // hasProducingTransform() doesn't apply to POutputValueBases
      // that aren't PValues or composites of PValues, e.g., PDone.
      return;
    }
    producingTransform = transform;
  }

  /**
   * Default behavior for {@link #finishSpecifyingOutput(PInput, PTransform)}} is
   * to do nothing. Override if your {@link PValue} requires
   * finalization.
   */
  @Override
  public void finishSpecifyingOutput(PInput input, PTransform<?, ?> transform) { }

  /**
   * The {@link PTransform} that produces this {@link POutputValueBase}.
   */
  private AppliedPTransform<?, ?, ?> producingTransform;
}

@@ -1672,43 +1672,13 @@
 * Re
-turns the %7B@link AppliedPTransform%7D
+cords
  tha
@@ -1708,21 +1708,16 @@
 lueBase%7D
-%0A   *
  is an o
@@ -1726,290 +1726,110 @@
 put 
-of.%0A   *%0A   * %3Cp%3EFor internal use only.%0A   */%0A  public AppliedPTransform%3C?, ?, ?%3E getProducingTransformInternal() %7B%0A    return producingTransform;%0A  %7D%0A%0A  /**%0A   * Records that this %7B@link POutputValueBase%7D is an output with the%0A   * given name of the given %7B@link AppliedPTransform%7D
+with the given name of the given %7B@link%0A   * AppliedPTransform%7D.%0A   *%0A   * %3Cp%3EBy default, does nothing
 .%0A  
@@ -1891,21 +1891,16 @@
 sOutput%7D
-%0A   *
  impleme
@@ -1908,17 +1908,16 @@
 tations.
- 
  Not to 
@@ -1926,16 +1926,21 @@
  invoked
+%0A   *
  directl
@@ -2045,754 +2045,8 @@
 m) %7B
-%0A    if (producingTransform != null) %7B%0A      // Already used this POutput as a PTransform output.  This can%0A      // happen if the POutput is an output of a transform within a%0A      // composite transform, and is also the result of the composite.%0A      // We want to record the %22immediate%22 atomic transform producing%0A      // this output, and ignore all later composite transforms that%0A      // also produce this output.%0A      //%0A      // Pipeline.applyInternal() uses !hasProducingTransform() to%0A      // avoid calling this operation redundantly, but%0A      // hasProducingTransform() doesn't apply to POutputValueBases%0A      // that aren't PValues or composites of PValues, e.g., PDone.%0A      return;%0A    %7D%0A    producingTransform = transform;%0A  
 %7D%0A%0A 
@@ -2316,150 +2316,7 @@
  %7B %7D
-%0A%0A  /**%0A   * The %7B@link PTransform%7D that produces this %7B@link POutputValueBase%7D.%0A   */%0A  private AppliedPTransform%3C?, ?, ?%3E producingTransform;
 %0A%7D%0A

Remove GetProducingTransformInternal