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

com.linkedin.dagli.producer.AbstractChildProducer Maven / Gradle / Ivy

Go to download

DAG-oriented machine learning framework for bug-resistant, readable, efficient, maintainable and trivially deployable models in Java and other JVM languages

There is a newer version: 15.0.0-beta9
Show newest version
package com.linkedin.dagli.producer;

import com.linkedin.dagli.producer.internal.ChildProducerInternalAPI;
import java.util.List;


/**
 * The base class for child (non-root) producers.
 *
 * @param  the type of result produced by the associated producer
 * @param  the type of the internal API provided by this producer
 * @param  the ultimate derived type of this producer
 */
public abstract class AbstractChildProducer, S extends AbstractChildProducer>
    extends AbstractProducer
    implements ChildProducer {
  private static final long serialVersionUID = 1;

  protected abstract class InternalAPI extends AbstractProducer.InternalAPI
      implements ChildProducerInternalAPI { }

  @Override
  public void validate() {
    super.validate();
    List> parents = this.internalAPI().getInputList();
    if (parents.isEmpty()) {
      throw new IllegalStateException(this.getName() + " is a child producer with no parents");
    }

    for (int i = 0; i < parents.size(); i++) {
      Producer parent = parents.get(i);
      if (parent == null) {
        throw new IllegalStateException(this.getName() + " has null parent producer as input #" + i
            + ".  This probably means you forgot to set an input on this transformer, e.g. using withInput(...).");
      } else if (parent == MissingInput.get()) {
        throw new IllegalStateException(this.getName() + " has a MissingInput parent producer as input #" + i
            + ".  This probably means you forgot to set an input on this transformer, e.g. using withInput(...).");
      }
    }
  }
}