platform/graphql_parser/lib/src/language/ast/boolean_value.dart
2019-08-07 22:45:42 -04:00

28 lines
730 B
Dart

import 'package:source_span/source_span.dart';
import 'input_value.dart';
import '../token.dart';
/// A GraphQL boolean value literal.
class BooleanValueContext extends InputValueContext<bool> {
bool _valueCache;
/// The source token.
final Token booleanToken;
BooleanValueContext(this.booleanToken) {
assert(booleanToken?.text == 'true' || booleanToken?.text == 'false');
}
/// The [bool] value of this literal.
bool get booleanValue => _valueCache ??= booleanToken.text == 'true';
/// Use [booleanToken] instead.
@deprecated
Token get BOOLEAN => booleanToken;
@override
FileSpan get span => booleanToken.span;
@override
bool computeValue(Map<String, dynamic> variables) => booleanValue;
}