summaryrefslogtreecommitdiff
path: root/src/main/java/au/id/zancanaro/javacheck/state/Command.java
blob: 78df8f1501b79f40f564d13e119b0cace74068d9 (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
package au.id.zancanaro.javacheck.state;

import au.id.zancanaro.javacheck.Generator;

public abstract class Command<S, A, R> {
    public Generator<A> argsGenerator(S state) {
        return Generator.pure(null);
    }

    public boolean preCondition(S state, A args) {
        return true;
    }

    public abstract R runCommand(S state, A args) throws Throwable;

    public S nextState(S state, A args, CommandValue<R> result) {
        return state;
    }

    public void postCondition(S oldState, S newState, A args, R result) throws Throwable {
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName();
    }
}