OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:source_span/source_span.dart'; |
| 6 |
| 7 import 'src/all.dart'; |
| 8 import 'src/impl.dart'; |
| 9 import 'src/none.dart'; |
| 10 |
| 11 /// A boolean expression that evaluates to `true` or `false` based on certain |
| 12 /// inputs. |
| 13 /// |
| 14 /// The syntax is mostly Dart's expression syntax restricted to boolean |
| 15 /// operations. See [the README][] for full details. |
| 16 /// |
| 17 /// [the README]: https://github.com/dart-lang/boolean_selector/blob/master/READ
ME.md |
| 18 abstract class BooleanSelector { |
| 19 /// A selector that accepts all inputs. |
| 20 static const all = const All(); |
| 21 |
| 22 /// A selector that accepts no inputs. |
| 23 static const none = const None(); |
| 24 |
| 25 /// All the variables in this selector, in the order they appear. |
| 26 Iterable<String> get variables; |
| 27 |
| 28 /// Parses [selector]. |
| 29 /// |
| 30 /// This will throw a [SourceSpanFormatException] if the selector is |
| 31 /// malformed or if it uses an undefined variable. |
| 32 factory BooleanSelector.parse(String selector) = BooleanSelectorImpl.parse; |
| 33 |
| 34 /// Returns whether the selector matches the given [semantics]. |
| 35 /// |
| 36 /// The [semantics] define which variables evaluate to `true` or `false`. The |
| 37 /// parameter can be either an `Iterable<String>` containing variables that |
| 38 /// should evaluate to `true`, or a function `bool semantics(String variable)` |
| 39 /// that returns a variable's value. |
| 40 bool evaluate(semantics); |
| 41 |
| 42 /// Returns a new [BooleanSelector] that matches only inputs matched by both |
| 43 /// [this] and [other]. |
| 44 BooleanSelector intersection(BooleanSelector other); |
| 45 |
| 46 /// Returns a new [BooleanSelector] that matches all inputs matched by either |
| 47 /// [this] or [other]. |
| 48 BooleanSelector union(BooleanSelector other); |
| 49 |
| 50 /// Throws a [FormatException] if any variables are undefined. |
| 51 /// |
| 52 /// The [isDefined] function should return `true` for any variables that are |
| 53 /// considered valid, and `false` for any invalid or undefined variables. |
| 54 void validate(bool isDefined(String variable)); |
| 55 } |
OLD | NEW |