matchesValueSpecifier function
Implementation
bool matchesValueSpecifier(
String valueSpecifier,
Map<String, dynamic> ?valueByNameMap
)
{
if ( valueByNameMap != null )
{
final match = valueExpression.firstMatch( valueSpecifier );
if ( match != null )
{
final String valueName = match.group( 1 )!;
final String operator = match.group( 2 )!;
dynamic otherValue = match.group( 3 )!;
if ( valueByNameMap.containsKey( valueName ) )
{
var value = valueByNameMap[ valueName ];
if ( value is num )
{
otherValue = num.tryParse( otherValue ) ?? 0;
}
if ( ( operator == '='
&& value == otherValue )
|| ( operator == '<'
&& value < otherValue )
|| ( operator == '<='
&& value <= otherValue )
|| ( operator == '>='
&& value >= otherValue )
|| ( operator == '>'
&& value > otherValue )
|| ( operator == '<>'
&& value != otherValue ) )
{
return true;
}
else
{
return false;
}
}
}
}
logWarning( 'Bad value specifier: $valueSpecifier' );
return false;
}