parse static method

List<ConditionKey> parse(
  1. String keys
)

Implementation

static List<ConditionKey> parse(String keys) {
  keys = keys.trim();
  if (keys.isEmpty) {
    throw ArgumentError('Empty key');
  }

  var list = _keyRegExp.allMatches(keys).map((m) {
    var s1 = m.group(1);
    if (s1 != null) {
      return ConditionKeyField(s1);
    }

    var s2 = m.group(2);
    if (s2 != null) {
      return ConditionKeyField(s2);
    }

    var field = m.group(3);
    if (field != null) {
      return ConditionKeyField(field);
    }

    var index = m.group(4);
    if (index != null) {
      var idx = int.parse(index);
      return ConditionKeyIndex(idx);
    }

    throw StateError('Invalid match: $m');
  }).toList();

  return list;
}