Private voidCreatereplytree (list<commentreplyvo> commentreplyvolist, list<commentreply>replylist) {if(Org.apache.commons.collections.CollectionUtils.isNotEmpty (replylist)) {List<CommentReply> leftreplylist =NewLinkedlist<commentreply>(); Leftreplylist.addall (replylist); for(commentreply reply:replylist) {Commentreplyvo Replyvo=transform (reply);if(Reply.getparentreplyid () = =NULL) {//Parentreplyid is null, it means a reply to the commentCommentreplyvolist.add (REPLYVO); Leftreplylist.remove (reply);}} Addreplytreenode (Commentreplyvolist, leftreplylist);}}Private voidSortreplytree (list<commentreplyvo> commentreplyvolist, list<commentreply>replylist) {if(Org.apache.commons.collections.CollectionUtils.isNotEmpty (replylist)) {List<CommentReply> leftreplylist =NewLinkedlist<commentreply>(); Leftreplylist.addall (replylist); for(commentreply reply:replylist) {Commentreplyvo Replyvo=transform (reply);if(Reply.getparentreplyid () = =NULL) {//Parentreplyid is null, it means a reply to the commentCommentreplyvolist.add (REPLYVO); Leftreplylist.remove (reply);}} Addreplytreenode (Commentreplyvolist, leftreplylist);}}Private voidAddreplytreenode (list<commentreplyvo> replyvolist, list<commentreply>replylist) {if(Org.apache.commons.collections.CollectionUtils.isNotEmpty (replyvolist) &&Org.apache.commons.collections.CollectionUtils.isNotEmpty (replylist)) {List<CommentReply> leftreplynodelist =NewLinkedlist<commentreply>(); Leftreplynodelist.addall (replylist); for(Commentreplyvo replyvo:replyvolist) { for(commentreply reply:replylist) {if(Reply.getparentreplyid ()! =NULL&&Reply.getparentreplyid (). Equals (Replyvo.getid ())) {Replyvo.getcommentreplyvos (). Add (transform (Reply)); Leftreplynodelist.remove (reply); }} for(Commentreplyvo replyvo:replyvolist) {Addreplytreenode (Replyvo.getcommentreplyvos (), leftReplyNodeList);//Recursive invocation}}}
Recursive use Cases