I am using lamdaj expressions to filter the lists based on certain criteria. Inorder to find matches hamcrest matcher is being used.
My question is, I would like to filter the list based on more than one condition using AND and OR operator and i do not know how to do it.
For example, At present i have the below expression
List<CheckPlanForecastData> filteredSubFleet = select(
forecastList,
having(on(CheckPlanForecastData.class).getSubFleetCode(),
Matchers.equalTo(report.getSubFleet())));
Here i have filtered the list based on getSubFleetCode(). I would like to add another criteria along with getSubFleetCode() which i do not know how construct the expression.
Please help.
Maybe you can use
Matchers.allOf
,Matchers.anyOf
andMatchers.not
to express your logic.Please check The Hamcrest Tutorial.
A simple sample: