A little bit explanation about code: ntTPla.values() contains Plans and inside some Plans can have Packages ( child's ). There are code, which adding Packages to Plans "ntTPla.addPackage". After this code ( when all packages will be added to Plans ) I should check Packages and delete wrong Packages. I wrote code, which checking if Packages is good and remove wrong ones. Question - how to return all Plans and new Packages near them? Because now code returning old ones. I debugged and removing working fine, just need to fix return. How my code should look like?
[...]
List<Plan> tPlan = new ArrayList<Plan>();
tPlan.addAll(ntTPla.values());
List<Packet> packetFirst = new ArrayList<Packet>();
packetFirst.addAll(tPlan.get(0).getPacket());
String test2 = null;
for (int i = 0 ; i < packetFirst.size(); i++){
if(packetFirst.get(i).getBest()) {
test2 = packetFirst.get(i).getCode();
break;
}
}
for (int ii = packetFirst.size() - 1 ; ii >= 0; ii--){
if(!packetFirst.get(ii).getCode().equals(test2)) {
packetFirst.remove(ii);
}
}
return ntTPla.values();