/* * Copyright (c) 2024, Antonio Gabriel Muñoz Conejo <antoniogmc at gmail dot com> * Distributed under the terms of the MIT License */ package com.github.tonivade.vavr.effect; record StateIO(boolean isCancelled, boolean isCancellingNow, boolean isStartingNow) { static final StateIO INITIAL = new StateIO(false, false, false); static final StateIO CANCELLED = new StateIO(true, false, false); StateIO cancellingNow() { return new StateIO(isCancelled, true, isStartingNow); } StateIO startingNow() { return new StateIO(isCancelled, isCancellingNow, true); } StateIO notStartingNow() { return new StateIO(isCancelled, isCancellingNow, false); } boolean isCancelable() { return !isCancelled && !isCancellingNow && !isStartingNow; } boolean isRunnable() { return !isCancelled && !isCancellingNow; } }