modList static method
TODO: This is a hack. Create a nicer way of handling this
Utility method that creates a list of modifications
when given a modList of triplets consisting of
modType - string value in the set [a,d,r,i]
(for add, delete, replace, increment)
followed by attribute,values
For example, the list
['r','sn', 'Mickey Mouse','i', 'age',null]
replaces the sn attribute with Mickey Mouse, and increments the age attribute by one.
Implementation
static List<Modification> modList(List modList) {
var list = <Modification>[];
for (var x in modList) {
assert(x.length == 3);
String op = x[0];
var attr = x[1];
var vals = x[2];
if (vals is! List) vals = [vals];
switch (op) {
case 'a':
list.add(Modification.add(attr, vals));
break;
case 'd':
list.add(Modification.delete(attr, vals));
break;
case 'r':
list.add(Modification.replace(attr, vals));
break;
case 'i':
list.add(Modification.increment(attr, vals));
break;
}
}
return list;
}