@@ -0,0 +1,2642 @@
+package at.ac.univie.isc.asio.tool;%0A%0Aimport javax.annotation.Nonnull;%0Aimport javax.annotation.concurrent.Immutable;%0Aimport java.util.Objects;%0A%0A/**%0A * Contain either a value or an error, that occurred while creating it.%0A */%0A@Immutable%0Apublic final class ValueOrError%3CVALUE%3E %7B%0A  /**%0A   * Create an instance holding a value.%0A   * @param value to hold%0A   * @param %3CT%3E type of contained value%0A   * @return value bearing ValueOrError%0A   */%0A  public static %3CT%3E ValueOrError%3CT%3E valid(@Nonnull final T value) %7B%0A    Objects.nonNull(value);%0A    return new ValueOrError%3C%3E(value, null);%0A  %7D%0A%0A  /**%0A   * Create an instance holding an error.%0A   * @param error to hold%0A   * @param %3CT%3E type of contained value%0A   * @return error bearing ValueOrError%0A   */%0A  public static %3CT%3E ValueOrError%3CT%3E invalid(@Nonnull final RuntimeException error) %7B%0A    Objects.nonNull(error);%0A    return new ValueOrError%3C%3E(null, error);%0A  %7D%0A%0A  private final VALUE value;%0A  private final RuntimeException error;%0A%0A  private ValueOrError(final VALUE value, final RuntimeException error) %7B%0A    assert ! (value == null && error == null) : %22value and error are null%22;%0A    this.value = value;%0A    this.error = error;%0A  %7D%0A%0A  /**%0A   * @return true if this holds a value%0A   */%0A  public boolean hasValue() %7B%0A    return error == null;%0A  %7D%0A%0A  /**%0A   * @return true if this holds an error%0A   */%0A  public boolean hasError() %7B%0A    return error != null;%0A  %7D%0A%0A  /**%0A   * @return contained error%0A   * @throws java.lang.IllegalStateException if no error is present%0A   */%0A  @Nonnull%0A  public RuntimeException error() %7B%0A    if (hasValue()) %7B%0A      throw new IllegalStateException(%22no error present%22);%0A    %7D%0A    return error;%0A  %7D%0A%0A  /**%0A   * @return contained value%0A   * @throws java.lang.IllegalStateException if no value is present%0A   */%0A  @Nonnull%0A  public VALUE get() %7B%0A    if (hasError()) %7B%0A      throw new IllegalStateException(%22no value present%22);%0A    %7D%0A    return value;%0A  %7D%0A%0A  @Override%0A  public boolean equals(final Object o) %7B%0A    if (this == o)%0A      return true;%0A    if (o == null %7C%7C getClass() != o.getClass())%0A      return false;%0A%0A    final ValueOrError that = (ValueOrError) o;%0A%0A    if (error != null ? !error.equals(that.error) : that.error != null)%0A      return false;%0A    if (value != null ? !value.equals(that.value) : that.value != null)%0A      return false;%0A    return true;%0A  %7D%0A%0A  @Override%0A  public int hashCode() %7B%0A    int result = value != null ? value.hashCode() : 0;%0A    result = 31 * result + (error != null ? error.hashCode() : 0);%0A    return result;%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    return %22ValueOrError%7B%22 + %22value=%22 + value + %22, error=%22 + error + '%7D';%0A  %7D%0A%7D%0A

Add ValueOrError as validation return type