conditionKeyValue method

Parser<Condition> conditionKeyValue()

Implementation

Parser<Condition> conditionKeyValue() =>
    (conditionKeys() & conditionOperator() & conditionValue()).map((l) {
      var keys = l[0] as List<ConditionKey>;
      var op = l[1] as String;
      var value = l[2];

      switch (op) {
        case '=':
        case '==':
          return KeyConditionEQ(keys, value);
        case '!=':
          return KeyConditionNotEQ(keys, value);
        case '=~':
          return KeyConditionIN(keys, value);
        case '!~':
          return KeyConditionNotIN(keys, value);
        case '>':
          return KeyConditionGreaterThan(keys, value);
        case '>=':
          return KeyConditionGreaterThanOrEqual(keys, value);
        case '<':
          return KeyConditionLessThan(keys, value);
        case '<=':
          return KeyConditionLessThanOrEqual(keys, value);
        default:
          throw FormatException('Unknown operator: $keys $op $value');
      }
    });