public boolean tryToMoveTo(State to) {
    AtomicReference<State> lastFrom = new AtomicReference<>();
    State newState = this.state.updateAndGet(from -> {
      lastFrom.set(from);
      if (TRANSITIONS.get(from).contains(to)) {
        return to;
      }
      return from;
    });

    boolean updated = newState == to && lastFrom.get() != to;
    LOG.trace("tryToMoveTo from {} to {} => {}", lastFrom.get(), to, updated);
    return updated;
  }
@Test
  public void can_move_to_HARD_STOPPING_from_any_step_but_from_INIT_HARD_STOPPING_and_STOPPED() {
    for (State state : values()) {
      boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(HARD_STOPPING);
      if (state == INIT || state == STOPPED || state == HARD_STOPPING) {
        assertThat(tryToMoveTo).describedAs("from state " + state).isFalse();
      } else {
        assertThat(tryToMoveTo).describedAs("from state " + state).isTrue();
      }
    }
  }