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

com.github.dakusui.actionunit.connectors.Pipe Maven / Gradle / Ivy

There is a newer version: 6.1.5
Show newest version
package com.github.dakusui.actionunit.connectors;

import com.github.dakusui.actionunit.Context;
import com.github.dakusui.actionunit.Utils;

import static com.github.dakusui.actionunit.connectors.Connectors.composeContextValues;

/**
 * Executes an operation based on an input value and gives an output value.
 *
 * @param  Type of input value
 * @param  Type of output value
 */
public interface Pipe {
  O apply(I input, Context context);

  abstract class Base implements Pipe {
    private final String description;

    protected Base(String description) {
      this.description = description;
    }

    protected Base() {
      this(null);
    }

    @Override
    public O apply(I input, Context context) {
      return this.apply(input, composeContextValues(context));
    }

    /**
     * Applies this pipe to {@code input}.
     *
     * @param input An input to apply this object.
     * @param outer Inputs from outer {@code With} actions.
     */
    abstract protected O apply(I input, Object... outer);

    @Override
    public String toString() {
      return this.description == null
          ? Utils.shortClassNameOf(this.getClass())
          : description;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy