com.farao_community.farao.swe.runner.api.resource.ThreadLauncherResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gridcapa-swe-runner-api Show documentation
Show all versions of gridcapa-swe-runner-api Show documentation
Client API to gridcapa swe process
/*
* Copyright (c) 2022, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.farao_community.farao.swe.runner.api.resource;
import java.util.Optional;
/**
* @author Theo Pascoli {@literal }
*/
public class ThreadLauncherResult {
private final Optional result;
private final boolean hasError;
private final Exception exception;
public ThreadLauncherResult(Optional result, boolean hasError, Exception exception) {
this.result = result;
this.hasError = hasError;
this.exception = exception;
}
public static ThreadLauncherResult success(U result) {
return new ThreadLauncherResult<>(Optional.of(result), false, null);
}
public static ThreadLauncherResult interrupt() {
return new ThreadLauncherResult<>(Optional.empty(), false, null);
}
public static ThreadLauncherResult error(Exception e) {
return new ThreadLauncherResult<>(Optional.empty(), true, e);
}
public Optional getResult() {
return result;
}
public boolean hasError() {
return hasError;
}
public Exception getException() {
return exception;
}
}