htFetch method
dynamic
htFetch(
- String varName
)
Implementation
dynamic htFetch(String varName) {
switch (varName) {
case 'toJson':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
jsonifyList(this);
case 'iterator':
return iterator;
case 'map':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return map((element) {
return func.call(positionalArgs: [element]);
});
};
case 'where':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return where((element) {
return func.call(positionalArgs: [element]);
});
};
case 'expand':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return expand((element) {
return func.call(positionalArgs: [element]) as Iterable;
});
};
case 'contains':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
contains(positionalArgs.first);
case 'reduce':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return reduce((value, element) {
return func.call(positionalArgs: [value, element]);
});
};
case 'fold':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
final initialValue = positionalArgs[0];
HTFunction func = positionalArgs[1];
return fold(initialValue, (value, element) {
return func.call(positionalArgs: [value, element]);
});
};
case 'every':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return every((element) {
return func.call(positionalArgs: [element]) as bool;
});
};
case 'join':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
join(positionalArgs.first);
case 'any':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return any((element) {
return func.call(positionalArgs: [element]) as bool;
});
};
case 'toList':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
toList();
case 'length':
return length;
case 'isEmpty':
return isEmpty;
case 'isNotEmpty':
return isNotEmpty;
case 'take':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
take(positionalArgs.first);
case 'takeWhile':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return takeWhile((element) {
return func.call(positionalArgs: [element]) as bool;
});
};
case 'skip':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
skip(positionalArgs.first);
case 'skipWhile':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
return skipWhile((element) {
return func.call(positionalArgs: [element]) as bool;
});
};
case 'first':
return first;
case 'last':
return last;
case 'single':
return single;
case 'firstWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
HTFunction? orElse = namedArgs['orElse'];
return firstWhere((element) {
return func.call(positionalArgs: [element]) as bool;
}, orElse: () {
return orElse != null ? orElse() : null;
});
};
case 'lastWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
HTFunction? orElse = namedArgs['orElse'];
return lastWhere((element) {
return func.call(positionalArgs: [element]) as bool;
}, orElse: () {
return orElse != null ? orElse() : null;
});
};
case 'singleWhere':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
HTFunction func = positionalArgs.first;
HTFunction? orElse = namedArgs['orElse'];
return singleWhere((element) {
return func.call(positionalArgs: [element]) as bool;
}, orElse: () {
return orElse != null ? orElse() : null;
});
};
case 'elementAt':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
elementAt(positionalArgs.first);
case 'toString':
return (HTEntity entity,
{List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) =>
toString();
default:
throw HTError.undefined(varName);
}
}