has method

bool has({
  1. String? action,
  2. String? state,
  3. bool conform = true,
})
override

Does an action exist in the state machine?

@param action The action in question. @return True if the action exists, false if it does not.

Implementation

bool has({String? action, String? state, bool conform = true}) {
  var result = false;
  bool stateActionExists = false;
  bool stateNameExists = false;

  if (action != null) {
    stateActionExists = _findStateTransitionByAction(action) != null;
  } else
    stateActionExists = state != null;

  if (state != null) {
    stateNameExists = _findStateMetaByName(state) != null;
  } else
    stateNameExists = stateActionExists;

  result = conform
      ? (stateActionExists && stateNameExists)
      : (stateActionExists || stateNameExists);

  return result;
}