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

com.github.bordertech.taskmaster.service.impl.ProcessingMutableResult Maven / Gradle / Ivy

package com.github.bordertech.taskmaster.service.impl;

import java.io.Serializable;

/**
 * Used to hold the service result with the ASync processing cache.
 *
 * @param  the meta data type
 * @param  the result type
 */
public final class ProcessingMutableResult implements Serializable {

	private final M metaData;
	private T result;
	private Exception exception;

	/**
	 * @param metaData the meta data
	 */
	public ProcessingMutableResult(final M metaData) {
		this.metaData = metaData;
	}

	/**
	 * @return the meta data
	 */
	public M getMetaData() {
		return metaData;
	}

	/**
	 * @return the polling result
	 */
	public T getResult() {
		return result;
	}

	/**
	 * @param result the result
	 */
	public void setResult(final T result) {
		this.result = result;
		this.exception = null;
	}

	/**
	 * @return the exception or null if has result
	 */
	public Exception getException() {
		return exception;
	}

	/**
	 * @param exception the exception when calling the service
	 */
	public void setException(final Exception exception) {
		this.exception = exception;
		this.result = null;
	}

	/**
	 * @return true if holding an exception
	 */
	public boolean isException() {
		return exception != null;
	}

	/**
	 * @return true if holding a result
	 */
	public boolean isResult() {
		return !isException();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy