-
Notifications
You must be signed in to change notification settings - Fork 1
Bio Expression Basics
Rajab Davudov edited this page Mar 13, 2019
·
2 revisions
Bio Expressions are created and used as following:
BioExpression expr = BioExpression.parse("car.year_of_production > 2015 and car.fuel_efficiency < 12.4") ;
and evaluated as following:
Car c = new Car() ;
c.set(Car.YEAR_OF_PRODUCTION, 2016) ;
c.set(Car.FUEL_EFFICIENCY, 11.2) ;
boolean result = (Boolean) expr.getValue(c) ;
Result will be true because condition is satisfied. If we are expecting a boolean to be returned we can also call as following:
boolean result = expr.getBooleanValue(c) ;
This method will cast return value to boolean.
Parsed Bio Expressions are stored inside internal cache, so parsing multiple times will not affect your application performance. If you parse exactly same expression again, it will return already parsed one from cache and since they are stateless objects there will be impact on your application logic.