summaryrefslogtreecommitdiff
path: root/src/main/java/au/id/zancanaro/javacheck/state/CommandResult.java
blob: 12f650da109609dee17844971a1d9f8617a3bf20 (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<State> {
    private final State state;
    private final Throwable thrown;

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

    public State getState() {
        return state;
    }

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

    public Throwable getThrown() {
        return thrown;
    }

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

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