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

fr.wseduc.cas.exceptions.Try Maven / Gradle / Ivy

package fr.wseduc.cas.exceptions;

public class Try {

	private final E exception;
	private final T value;

	public Try(E exception) {
		this.exception = exception;
		this.value = null;
	}

	public Try(T value) {
		this.exception = null;
		this.value = value;
	}

	public T get() throws E {
		if(exception == null) {
			return value;
		}
		throw exception;
	}

	public boolean isSuccess() {
		return exception == null;
	}

	public boolean isFailure() {
		return !isSuccess();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy