com.cyngn.vertx.async.ResultContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-util Show documentation
Show all versions of vertx-util Show documentation
A library for using opentsdb with vert.x
package com.cyngn.vertx.async;
/**
* Handles wrapping what occurred as a result of an async operation.
*
* @author [email protected] (Jeremy Truelove) 9/3/15
*/
public class ResultContext {
public final boolean succeeded;
public final Throwable error;
public final String errorMessage;
public final T value;
/**
* Creates a new result context that represents an operation that completed without error.
*
* @param succeeded True if the operation was successful, false otherwise.
*/
public ResultContext(boolean succeeded) {
this.succeeded = succeeded;
this.value = null;
this.error = null;
this.errorMessage = null;
}
/**
* Creates a new result context that represents an operation that completed without error.
*
* @param succeeded True if the operation was successful, false otherwise.
* @param value The resulting value.
*/
public ResultContext(boolean succeeded, T value) {
this.succeeded = succeeded;
this.value = value;
this.error = null;
this.errorMessage = null;
}
/**
* Creates a new result context that represents a failed async operation.
*
* @param error The {@link Throwable} error that was the result of the operation.
* @param errorMessage The error message.
*/
public ResultContext(Throwable error, String errorMessage) {
this.succeeded = false;
this.value = null;
this.error = error;
this.errorMessage = errorMessage;
}
}