summaryrefslogtreecommitdiff
path: root/src/main/java/com/it_jaros/jscanner/PollState.java
blob: 474c055ef87a9df574ffac8e2d86f241eadb99ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
package com.it_jaros.jscanner;

/**
 * A sealed interface representing the three possible outcomes of a CompletionService
 * poll operation: successful result, task failure, or not ready yet.
 * Makes error handling explicit — Failure and Unavailable are distinct and compile-time
 * required to handle via exhaustiveness checking in switch statements.
 */
public sealed interface PollState<T> {
    record Success<T>(T value) implements PollState<T> {}
    record Failure<T>(Throwable error) implements PollState<T> {}
    record Unavailable<T>() implements PollState<T> {}
}