summaryrefslogtreecommitdiff
path: root/src/main/java/au/id/zancanaro/javacheck/state/CommandResult.java
blob: cc2f5baa61143a9e1925315461c7ecae0c321b58 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package au.id.zancanaro.javacheck.state;

public class CommandResult<S> {
    private final S state;
    private final Throwable thrown;

    private CommandResult(S state, Throwable thrown) {
        this.state = state;
        this.thrown = thrown;
    }

    public S getState() {
        return state;
    }

    public boolean isFailed() {
        return thrown != null;
    }

    public Throwable getThrown() {
        return thrown;
    }

    public static <S> CommandResult<S> success(S state) {
        return new CommandResult<>(state, null);
    }

    public static <S> CommandResult<S> fail(S state, Throwable ex) {
        return new CommandResult<>(state, ex);
    }
}