checkStatesAreValid method

void checkStatesAreValid(
  1. ChangeType? changeType,
  2. NotifyState? notifyState,
  3. UiType? uiType
)

Implementation

void checkStatesAreValid(
    ChangeType? changeType, NotifyState? notifyState, UiType? uiType) {
  if (uiType != null) {
    if (changeType != ChangeType.NOTIFY)
      throw SqlException(SqlExceptionEnum.FAILED_SELECT,
          cause: "ui_type can only contain values when change_type=NOTIFY");
  }
  if (notifyState == null) return;
  if (changeType == ChangeType.NOTIFY) {
    if (notifyState != NotifyState.CLIENT_UP_TO_DATE &&
        notifyState != NotifyState.CLIENT_OUT_OF_DATE) {
      throw SqlException(SqlExceptionEnum.FAILED_SELECT,
          cause:
              "Invalid combination of change_type: $changeType and notify_state: $notifyState");
    }
  } else {
    // Not NOTIFY
    if (notifyState != NotifyState.CLIENT_STORED &&
        notifyState != NotifyState.CLIENT_SENT) {
      throw SqlException(SqlExceptionEnum.FAILED_SELECT,
          cause:
              "Invalid combination of change_type: $changeType and notify_state: $notifyState");
    }
  }
}