Use implements instead of extends
This commit is contained in:
parent
6133e58226
commit
692ad41502
2 changed files with 10 additions and 8 deletions
2
TODO.md
2
TODO.md
|
|
@ -18,7 +18,7 @@
|
||||||
- [X] Create Formula.toStringLiteral. It is the reverse of Formula.fromSet( Formula.fromArrayStringLiteral(string)[0] )
|
- [X] Create Formula.toStringLiteral. It is the reverse of Formula.fromSet( Formula.fromArrayStringLiteral(string)[0] )
|
||||||
- [X] Create UnitSpec.toStringLiteral, like Formula.toStringLiteral
|
- [X] Create UnitSpec.toStringLiteral, like Formula.toStringLiteral
|
||||||
- [X] Make Formula and UnitSpec subclasses of FormulaElement. Change return type of functions that return Object to FormulaElement if necessary.
|
- [X] Make Formula and UnitSpec subclasses of FormulaElement. Change return type of functions that return Object to FormulaElement if necessary.
|
||||||
- [ ] Define toStringLiteral in FormulaElement.
|
- [X] Define toStringLiteral in FormulaElement.
|
||||||
- Database file location:
|
- Database file location:
|
||||||
- [ ] In linux, the sqlite database file will be located following rules at https://specifications.freedesktop.org/basedir/latest/
|
- [ ] In linux, the sqlite database file will be located following rules at https://specifications.freedesktop.org/basedir/latest/
|
||||||
- [ ] In Windows, the sqlite database file will be in %appdata%/Roaming
|
- [ ] In Windows, the sqlite database file will be in %appdata%/Roaming
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,13 @@ List<FormulaElement> parseCorpusElements(String arrayStringLiteral) {
|
||||||
typedef Number = double;
|
typedef Number = double;
|
||||||
|
|
||||||
/// Abstract base class for formula elements
|
/// Abstract base class for formula elements
|
||||||
abstract class FormulaElement {}
|
abstract class FormulaElement {
|
||||||
|
/// Creates a string literal representation of the FormulaElement that can be parsed
|
||||||
|
/// by the D4RT parser to recreate the same FormulaElement object.
|
||||||
|
String toStringLiteral();
|
||||||
|
}
|
||||||
|
|
||||||
class UnitSpec extends FormulaElement {
|
class UnitSpec implements FormulaElement {
|
||||||
final String name;
|
final String name;
|
||||||
final String baseUnit;
|
final String baseUnit;
|
||||||
final String symbol;
|
final String symbol;
|
||||||
|
|
@ -136,8 +140,7 @@ class UnitSpec extends FormulaElement {
|
||||||
return units.toList(growable: false);
|
return units.toList(growable: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a string literal representation of the UnitSpec that can be parsed
|
@override
|
||||||
/// by the D4RT parser to recreate the same UnitSpec object.
|
|
||||||
String toStringLiteral() {
|
String toStringLiteral() {
|
||||||
final buffer = StringBuffer('{');
|
final buffer = StringBuffer('{');
|
||||||
buffer.write('"name": "$name", "symbol": "$symbol"');
|
buffer.write('"name": "$name", "symbol": "$symbol"');
|
||||||
|
|
@ -194,8 +197,7 @@ class VariableSpec {
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(unit, name, values != null ? const DeepCollectionEquality().hash(values!) : 0);
|
int get hashCode => Object.hash(unit, name, values != null ? const DeepCollectionEquality().hash(values!) : 0);
|
||||||
|
|
||||||
/// Creates a string literal representation of the VariableSpec that can be parsed
|
@override
|
||||||
/// by the D4RT parser.
|
|
||||||
String toStringLiteral() {
|
String toStringLiteral() {
|
||||||
final buffer = StringBuffer('{');
|
final buffer = StringBuffer('{');
|
||||||
buffer.write('"name": "$name"');
|
buffer.write('"name": "$name"');
|
||||||
|
|
@ -219,7 +221,7 @@ class VariableSpec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Formula extends FormulaElement {
|
class Formula implements FormulaElement {
|
||||||
final String name;
|
final String name;
|
||||||
final String? description;
|
final String? description;
|
||||||
final List<VariableSpec> input;
|
final List<VariableSpec> input;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue