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

uk.ac.liv.pgb.analytica.lib.TaskExecutionResult Maven / Gradle / Ivy

Go to download

Library allowing generation of plots and data from proteomics and metabolomics mass spectrometry data through the use of R and java methods.

The newest version!
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package uk.ac.liv.pgb.analytica.lib;

/**
 * Describes the result of a task.
 * @author sperkins
 */
public final class TaskExecutionResult {
    /**
     * The exception reported by the task, if any.
     */
    private Exception ex = null;

    /**
     * The error message reported by the task, if any.
     */
    private String errorMessage = null;

    /**
     * The success message reported by the task, if any.
     */
    private String successMessage = null;

    /**
     * Private constructor to prevent external instantiation.
     */
    private TaskExecutionResult() { }

    /**
     * Creates an instance of this class denoting a successful task execution.
     * @param successMessage The success message.
     * @return The success result object.
     */
    public static TaskExecutionResult success(final String successMessage) {
        TaskExecutionResult result = new TaskExecutionResult();
        result.successMessage = successMessage;
        return result;
    }

    /**
     * Creates an instance of this class denoting an unsuccessful task execution.
     * @param errorMessage The error message.
     * @param ex The exception reported by the task.
     * @return The unsuccessful result object.
     */
    public static TaskExecutionResult error(final String errorMessage, final Exception ex) {
        TaskExecutionResult result = new TaskExecutionResult();
        result.errorMessage = errorMessage;
        result.ex = ex;
        return result;
    }

    /**
     * Gets the exception contained in this result, if any.
     * @return The exception contained in this result.
     */
    public Exception getException() {
        return this.ex;
    }

    /**
     * Gets the success message in this result, if any.
     * @return The success message.
     */
    public String getSuccessMessage() {
        return this.successMessage;
    }

    /**
     * Gets the error message, if any.
     * @return The error message.
     */
    public String getErrorMessage() {
        return this.errorMessage;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy