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

com.github.valid8j.pcond.core.EvaluableIo Maven / Gradle / Ivy

Go to download

Java Library Providing Uniformed Programming Experiences across DbC, Value Checking, and Test Assertions

The newest version!
package com.github.valid8j.pcond.core;

import static com.github.valid8j.pcond.core.EvaluationContext.formNameOf;
import static java.util.Objects.requireNonNull;

public class EvaluableIo, O> {
  private final ValueHolder input;
  private final E                    evaluable;
  private final EvaluationEntry.Type evaluableType;
  private final String               formName;
  private ValueHolder output;

  public EvaluableIo(ValueHolder input, EvaluationEntry.Type evaluableType, E evaluable) {
    this(input, evaluableType, formNameOf(evaluableType, evaluable), evaluable);
  }

  public EvaluableIo(ValueHolder input, EvaluationEntry.Type evaluableType, String formName, E evaluable) {
    this.input = requireNonNull(input);
    this.evaluableType = requireNonNull(evaluableType);
    this.formName = formName;
    this.evaluable = requireNonNull(evaluable);
    this.output = ValueHolder.create();
  }

  public void output(ValueHolder output) {
    this.output = requireNonNull(output).clone();
  }

  public ValueHolder input() {
    return this.input;
  }

  public EvaluationEntry.Type evaluableType() {
    return this.evaluableType;
  }

  public String formName() {
    return this.formName;
  }

  public E evaluable() {
    return this.evaluable;
  }

  public ValueHolder output() {
    return this.output;
  }

  @Override
  public String toString() {
    return "evaluable:<" + evaluableType + ":" + evaluable + "> in:" + input + " out:" + output;
  }
}