Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ParentService {
- public getParentList(String parentSetLookup) {
- List<Parent> parentList = getParentList(parentSetLookup);
- List<Integer> parentIdList = getParentIds(parentList);
- List<ChildOne> childOneList = getChildOneList(parentIdList);
- List<ChildTwo> childTwoList = getChildTwoList(parentIdList);
- List<ChildThree> childthreeList = getChildThreeList(parentIdList);
- mapChildrenToParent(parentList, childOneList);
- mapChildrenToParent(parentList, childTwoList);
- mapChildrenToParent(parentList, childThreeList);
- return parentList;
- }
- private void mapChildrenToParent(List<Parent> parentList, List<ChildBaseClass> childList) {
- for (Parent parent : parentList) {
- for (ChildBaseClass child : childList) {
- if (child.getParentId().equals(parent.getParentId())) {
- %%%parent.getChildList().add(child);%%%
- }
- }
- }
- }
- public class GrandParent {
- List<Parent> parent = new ArrayList<>();
- // Getter and Setter
- }
- public class Parent {
- private Integer parentId;
- private List<ChildOne> childOneList = new ArrayList<>();
- private List<ChildTwo> childTwoList = new ArrayList<>();
- private List<ChildThree> childThreeList = new ArrayList<>();
- // Getters and Setters
- }
- public abstract class ChildBaseClass {
- private Integer parentId;
- // Getter Setter
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement