![JAR search and dependency download from the Maven repository](/logo.png)
com.dslplatform.compiler.client.Either Maven / Gradle / Ivy
package com.dslplatform.compiler.client;
public final class Either {
private final T value;
private final Exception error;
private Either(final T value, final Exception error) {
this.value = value;
this.error = error;
}
public boolean isSuccess() {
return error == null;
}
public T get() {
return value;
}
public Exception whyNot() {
return error;
}
public String explainError() { return error.getMessage(); }
public static Either success(final S value) {
return new Either(value, null);
}
public static Either fail(final String error) {
return new Either(null, new Exception(error));
}
public static Either fail(final Exception error) {
return new Either(null, error);
}
public static Either fail(final String description, final Exception error) {
return new Either(null, new Exception(description, error));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy