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.
|
2019-08-08 02:45:42 +00:00
|
|
|
final Token booleanToken;
|
2019-08-08 02:34:23 +00:00
|
|
|
|
2019-08-08 02:45:42 +00:00
|
|
|
BooleanValueContext(this.booleanToken) {
|
|
|
|
assert(booleanToken?.text == 'true' || booleanToken?.text == 'false');
|
2017-01-25 04:28:09 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 02:34:23 +00:00
|
|
|
/// The [bool] value of this literal.
|
2019-08-08 02:45:42 +00:00
|
|
|
bool get booleanValue => _valueCache ??= booleanToken.text == 'true';
|
2019-08-08 02:34:23 +00:00
|
|
|
|
2019-08-08 02:45:42 +00:00
|
|
|
/// Use [booleanToken] instead.
|
2019-08-08 02:34:23 +00:00
|
|
|
@deprecated
|
2019-08-08 02:45:42 +00:00
|
|
|
Token get BOOLEAN => booleanToken;
|
2017-07-03 15:37:35 +00:00
|
|
|
|
|
|
|
@override
|
2019-08-08 02:45:42 +00:00
|
|
|
FileSpan get span => booleanToken.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
|
|
|
}
|