I have three object classes:
public class Section{
    private Integer id;
    private List<Program> programs;
}
public class Program{
    private String title;
    private Integer id;
    private List<Broadcast> broadcasts = null;
}
public class Broadcast {
    private Integer id;
    private String title;
}
And I have two lists of Section object: List<Section> oldSections and List<Section> newSections. I need to check if oldSections contains all Sections from newSections list, to determine this I have to compare id values. if it doesn't then I need to add this Section to oldSections and if it does then I have to do the same check for Programs and Broadcasts.
I tried to iterate through all Sections, Programs and Broadcasts but it doesn't seem to be a good solution. What would the best approach?
    private void updateSections(List<Section> oldSections, List<Section> newSections){
        for(Section newSection: newSections){
            boolean alreadyAdded = false;
            for(Section oldSection: oldSections){
                if(newSection.getId() == oldSection.getId()){
                    alreadyAdded = true;
                }
            }
            if(!alreadyAdded){
                oldSections.add(newSection);
            } else {
                //HERE I HAVE TO COMPARE PROGRAMS AND THEN BROADCASTS
            }
        }
    }
 
     
    