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

de.intarsys.tools.lang.CallableAdapter Maven / Gradle / Ivy

There is a newer version: 4.11
Show newest version
package de.intarsys.tools.lang;

import java.util.concurrent.Callable;

abstract public class CallableAdapter implements Runnable, Callable {

	private T result = null;

	private Exception exception;

	public T getResult() throws Exception {
		if (exception != null) {
			throw exception;
		}
		return result;
	}

	public T getResultUnchecked() {
		if (exception != null) {
			return null;
		}
		return result;
	}

	@Override
	public void run() {
		try {
			setResult(call());
		} catch (Exception e) {
			exception = e;
		}
	}

	protected void setResult(T result) {
		this.result = result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy