// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
// 
//     /**
//      * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
//      * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
//      * <p>
//      * Calling it from the constructor is a hazard and will generally cause failures.
//      */
//     @SuppressWarnings("unused")
//     void initialize();
// 
// }
// 
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java
// public final class ExceptionHandler {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);
//     private static final double ERROR_FIELD_MARGIN_SIZE = 20.0;
// 
//     private final Throwable exception;
// 
//     /**
//      * Creates an instance with the given exception.
//      *
//      * @param exception The exception to base this instance on
//      */
//     public ExceptionHandler(final Throwable exception) {
//         LOG.debug("Generating ExceptionPane for exception of type {}", exception.getClass());
//         this.exception = exception;
//     }
// 
//     /**
//      * @return The exception in a pane with {@link Throwable#getMessage()} as a label over the stacktrace.
//      */
//     public Pane asPane() {
//         return this.asPane(this.exception.getMessage());
//     }
// 
//     /**
//      * Same as {@link #asPane()} but with a custom error label on top of the stack trace.
//      *
//      * @param userReadableError The custom error message.
//      *
//      * @return The exception in a pane with the custom error message as a label over the stacktrace.
//      */
//     public Pane asPane(final String userReadableError) {
//         LOG.debug("Generating node corresponding to ExceptionPane...");
//         final Label messageLabel = new Label(userReadableError);
//         final TextArea throwableDataLabel = new TextArea(formatErrorMessage(this.exception));
// 
//         AnchorPane.setLeftAnchor(messageLabel, ERROR_FIELD_MARGIN_SIZE);
//         Nodes.centerNode(throwableDataLabel, ERROR_FIELD_MARGIN_SIZE);
//         return new AnchorPane(messageLabel, throwableDataLabel);
//     }
// 
//     public static Pane fromThrowable(final Throwable throwable) {
//         return new ExceptionHandler(throwable).asPane();
//     }
// 
//     /**
//      * Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
//      *
//      * @param title     The title of the error pop-up
//      * @param readable  The custom label to display on top of the stack trace
//      * @param exception The exception to use
//      *
//      * @return a {@link CompletionStage} to know when the pop-up displayed and have a handle on it.
//      */
//     public static CompletionStage<Stage> displayExceptionPane(
//         final String title,
//         final String readable,
//         final Throwable exception
//     ) {
//         final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
//         final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
//         return exceptionStage.thenCompose(Stages::scheduleDisplaying);
//     }
// 
//     private static String formatErrorMessage(final Throwable throwable) {
//         return "Message : \n" +
//                throwable.getMessage() +
//                "\nStackTrace:\n" +
//                Arrays.stream(throwable.getStackTrace())
//                      .map(StackTraceElement::toString)
//                      .collect(Collectors.joining("\n"));
//     }
// 
// }


import java.util.Objects;
import java.util.function.Consumer;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.Tuple;
import io.vavr.collection.List;
import io.vavr.collection.Seq;
import io.vavr.control.Try;
     * successes (in the sense of {@link Try#isSuccess()} and be non-null values.
     */
    private void ensureCorrectlyLoaded() {
        if (node.isFailure()) {
            throw new IllegalStateException("Node did not properly load!", node.getCause());
        }
        if (controller.isFailure()) {
            throw new IllegalStateException("Controller did not properly load!", controller.getCause());
        }

        Objects.requireNonNull(node.get(), "The node did not load properly and was null.");
        Objects.requireNonNull(controller.get(), "The controller did not load properly and was null.");
    }

    /**
     * @return The result of the attempt to load the {@link Node} as a {@link Try} instance.
     */
    public Try<NODE> getNode() {
        return node;
    }

    /**
     * @return The result of the attempt to build the controller associated to the node as a {@link Try} instance.
     */
    public Try<CONTROLLER> getController() {
        return controller;
    }

    public Try<Pane> orExceptionPane() {
        //noinspection unchecked
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java
// public interface FxmlController {
// 
//     /**
//      * This method is automatically called by the JavaFX {@link Platform} as soon as all the components are loaded (not
//      * necessarily rendered). This is where initial UX/UI setup should be done (enabling, disabling hiding etc...)
//      * <p>
//      * Calling it from the constructor is a hazard and will generally cause failures.
//      */
//     @SuppressWarnings("unused")
//     void initialize();
// 
// }
// 
// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/exception/ExceptionHandler.java
// public final class ExceptionHandler {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);
//     private static final double ERROR_FIELD_MARGIN_SIZE = 20.0;
// 
//     private final Throwable exception;
// 
//     /**
//      * Creates an instance with the given exception.
//      *
//      * @param exception The exception to base this instance on
//      */
//     public ExceptionHandler(final Throwable exception) {
//         LOG.debug("Generating ExceptionPane for exception of type {}", exception.getClass());
//         this.exception = exception;
//     }
// 
//     /**
//      * @return The exception in a pane with {@link Throwable#getMessage()} as a label over the stacktrace.
//      */
//     public Pane asPane() {
//         return this.asPane(this.exception.getMessage());
//     }
// 
//     /**
//      * Same as {@link #asPane()} but with a custom error label on top of the stack trace.
//      *
//      * @param userReadableError The custom error message.
//      *
//      * @return The exception in a pane with the custom error message as a label over the stacktrace.
//      */
//     public Pane asPane(final String userReadableError) {
//         LOG.debug("Generating node corresponding to ExceptionPane...");
//         final Label messageLabel = new Label(userReadableError);
//         final TextArea throwableDataLabel = new TextArea(formatErrorMessage(this.exception));
// 
//         AnchorPane.setLeftAnchor(messageLabel, ERROR_FIELD_MARGIN_SIZE);
//         Nodes.centerNode(throwableDataLabel, ERROR_FIELD_MARGIN_SIZE);
//         return new AnchorPane(messageLabel, throwableDataLabel);
//     }
// 
//     public static Pane fromThrowable(final Throwable throwable) {
//         return new ExceptionHandler(throwable).asPane();
//     }
// 
//     /**
//      * Creates a pop-up and displays it based on a given exception, pop-up title and custom error message.
//      *
//      * @param title     The title of the error pop-up
//      * @param readable  The custom label to display on top of the stack trace
//      * @param exception The exception to use
//      *
//      * @return a {@link CompletionStage} to know when the pop-up displayed and have a handle on it.
//      */
//     public static CompletionStage<Stage> displayExceptionPane(
//         final String title,
//         final String readable,
//         final Throwable exception
//     ) {
//         final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
//         final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
//         return exceptionStage.thenCompose(Stages::scheduleDisplaying);
//     }
// 
//     private static String formatErrorMessage(final Throwable throwable) {
//         return "Message : \n" +
//                throwable.getMessage() +
//                "\nStackTrace:\n" +
//                Arrays.stream(throwable.getStackTrace())
//                      .map(StackTraceElement::toString)
//                      .collect(Collectors.joining("\n"));
//     }
// 
// }


// Path: easyfxml/src/main/java/moe/tristan/easyfxml/model/fxml/FxmlLoadResult.java
import java.util.Objects;
import java.util.function.Consumer;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.model.exception.ExceptionHandler;
import io.vavr.Tuple;
import io.vavr.collection.List;
import io.vavr.collection.Seq;
import io.vavr.control.Try;

     * successes (in the sense of {@link Try#isSuccess()} and be non-null values.
     */
    private void ensureCorrectlyLoaded() {
        if (node.isFailure()) {
            throw new IllegalStateException("Node did not properly load!", node.getCause());
        }
        if (controller.isFailure()) {
            throw new IllegalStateException("Controller did not properly load!", controller.getCause());
        }

        Objects.requireNonNull(node.get(), "The node did not load properly and was null.");
        Objects.requireNonNull(controller.get(), "The controller did not load properly and was null.");
    }

    /**
     * @return The result of the attempt to load the {@link Node} as a {@link Try} instance.
     */
    public Try<NODE> getNode() {
        return node;
    }

    /**
     * @return The result of the attempt to build the controller associated to the node as a {@link Try} instance.
     */
    public Try<CONTROLLER> getController() {
        return controller;
    }

    public Try<Pane> orExceptionPane() {
        //noinspection unchecked
        return ((Try<Pane>) getNode()).recover(ExceptionHandler::fromThrowable);