Implementation
dynamic htFetch(String varName) {
switch (varName) {
case 'add':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
add(positionalArgs.first);
case 'addAll':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
addAll(positionalArgs.first);
case 'reversed':
return reversed;
case 'indexOf':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
indexOf(positionalArgs[0], positionalArgs[1]);
case 'lastIndexOf':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
lastIndexOf(positionalArgs[0], positionalArgs[1]);
case 'insert':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
insert(positionalArgs[0], positionalArgs[1]);
case 'insertAll':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
insertAll(positionalArgs[0], positionalArgs[1]);
case 'clear':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
clear();
case 'remove':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
remove(positionalArgs.first);
case 'removeAt':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
removeAt(positionalArgs.first);
case 'removeLast':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
removeLast();
case 'sublist':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
sublist(positionalArgs[0], positionalArgs[1]);
case 'asMap':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
asMap();
case 'sort':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction? func = positionalArgs.first;
int Function(dynamic, dynamic)? sortFunc;
if (func != null) {
sortFunc = (a, b) {
return func.call(positionalArgs: [a, b]) as int;
};
}
sort(sortFunc);
};
case 'shuffle':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
shuffle();
case 'indexWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
int start = positionalArgs[1];
return indexWhere((element) {
return func.call(positionalArgs: [element]) as bool;
}, start);
};
case 'lastIndexWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
int? start = positionalArgs[1];
return lastIndexWhere((element) {
return func.call(positionalArgs: [element]) as bool;
}, start);
};
case 'removeWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
removeWhere((element) {
return func.call(positionalArgs: [element]) as bool;
});
};
case 'retainWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
retainWhere((element) {
return func.call(positionalArgs: [element]) as bool;
});
};
case 'getRange':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
getRange(positionalArgs[0], positionalArgs[1]);
case 'setRange':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
setRange(positionalArgs[0], positionalArgs[1], positionalArgs[2],
positionalArgs[3]);
case 'removeRange':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
removeRange(positionalArgs[0], positionalArgs[1]);
case 'fillRange':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
fillRange(positionalArgs[0], positionalArgs[1], positionalArgs[2]);
case 'replaceRange':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
replaceRange(
positionalArgs[0], positionalArgs[1], positionalArgs[2]);
default:
// ignore: unnecessary_cast
return (this as Iterable).htFetch(varName);
}
}