Can have few plans and few tariffs. Need to remove all tariffs from plan, when remove == N
. Tried to do it with this code, but nothing happens. I mean, I debugged and saw in console, that remove is T
, but code don't remove tariffs anyway. How to fix removing?
remove = "Y";
List<Plan> plan = new ArrayList<Plan>();
plan.addAll(plan2);
for (int i = 0; i < plan.size(); i++) {
List<Tariff> tariff = new ArrayList<Tariff>();
tariff.addAll(plan.get(i).getTariff());
for (int j = 0; j < tariff.size(); j++) {
if(tariff.get(j).getCode().equals("N")) {
remove = "N";
}
}
plan.get(i).getTariff().removeIf(condition -> remove.equals("Y"));
}