platform/graphql_parser/lib/src/language/ast/boolean_value.dart

29 lines
690 B
Dart
Raw Normal View History

2017-07-05 22:44:13 +00:00
import 'package:source_span/source_span.dart';
2019-08-08 01:45:24 +00:00
import 'input_value.dart';
import '../token.dart';
2017-01-22 23:15:53 +00:00
2019-08-08 02:34:23 +00:00
/// A GraphQL boolean value literal.
2019-08-08 01:45:24 +00:00
class BooleanValueContext extends InputValueContext<bool> {
2017-07-03 15:37:35 +00:00
bool _valueCache;
2017-01-22 23:15:53 +00:00
2019-08-08 02:34:23 +00:00
/// The source token.
final Token boolean;
BooleanValueContext(this.boolean) {
assert(boolean?.text == 'true' || boolean?.text == 'false');
2017-01-25 04:28:09 +00:00
}
2019-08-08 02:34:23 +00:00
/// The [bool] value of this literal.
bool get booleanValue => _valueCache ??= boolean.text == 'true';
/// Use [boolean] instead.
@deprecated
Token get BOOLEAN => boolean;
2017-07-03 15:37:35 +00:00
@override
2019-08-08 02:34:23 +00:00
FileSpan get span => boolean.span;
2017-01-22 23:15:53 +00:00
@override
2019-08-08 01:45:24 +00:00
bool computeValue(Map<String, dynamic> variables) => booleanValue;
2017-01-22 23:15:53 +00:00
}