public class Workflow {
  enum State { DRAFT, READY, QUEUED }
  static final class Job {
    State state = State.DRAFT;
    void configure(boolean mappingValid) {
      if (state != State.DRAFT || !mappingValid) throw new IllegalStateException("Cannot configure");
      state = State.READY;
    }
    void queue() {
      if (state != State.READY) throw new IllegalStateException("Not ready");
      state = State.QUEUED;
    }
  }
  public static void main(String[] args) {
    var job = new Job();
    try { job.queue(); throw new AssertionError("Invalid start accepted"); }
    catch (IllegalStateException expected) { System.out.println(expected.getMessage()); }
    job.configure(true); job.queue(); System.out.println(job.state);
  }
}
