package team.unstudio.udpl.util;

import javax.annotation.Nullable;

import com.google.common.base.Strings;

public final class Result {

	private static final Result SUCCESS_RESULT = new Result(true);

	public static Result success() {
		return SUCCESS_RESULT;
	}

	public static Result failure(String message) {
		return new Result(false, message);
	}

	public static Result failure(Throwable throwable) {
		return new Result(false, throwable);
	}

	public static Result failure(String message, Throwable throwable) {
		return new Result(false, message, throwable);
	}

	private final boolean success;
	private final String message;
	private final Throwable throwable;

	private Result(boolean success) {
		this(success, null, null);
	}

	private Result(boolean success, String message) {
		this(success, message, null);
	}

	private Result(boolean success, Throwable throwable) {
		this(success, null, throwable);
	}

	private Result(boolean success, String message, Throwable throwable) {
		this.success = success;
		this.message = Strings.nullToEmpty(message);
		this.throwable = throwable;
	}

	public boolean isSuccess() {
		return success;
	}

	public boolean isFailure() {
		return !success;
	}

	public String getMessage() {
		return message;
	}

	@Nullable
	public Throwable getThrowable() {
		return throwable;
	}
}

@@ -266,24 +266,95 @@
 RESULT;%0D%0A%09%7D%0D
+%0A%09%0D%0A%09public static Result failure() %7B%0D%0A%09%09return new Result(false);%0D%0A%09%7D%0D
 %0A%0D%0A%09public s

Update Result