+ private List<Object> collectEventsForChangesInSone(Sone oldSone, Sone newSone) {
+ List<Object> events = new ArrayList<>();
+ SoneComparison soneComparison = new SoneComparison(oldSone, newSone);
+ for (Post newPost : soneComparison.getNewPosts()) {
+ if (newPost.getSone().equals(newSone)) {
+ newPost.setKnown(true);
+ } else if (newPost.getTime() < database.getFollowingTime(newSone.getId())) {
+ newPost.setKnown(true);
+ } else if (!newPost.isKnown()) {
+ events.add(new NewPostFoundEvent(newPost));
+ }
+ }
+ for (Post post : soneComparison.getRemovedPosts()) {
+ events.add(new PostRemovedEvent(post));
+ }
+ for (PostReply postReply : soneComparison.getNewPostReplies()) {
+ if (postReply.getSone().equals(newSone)) {
+ postReply.setKnown(true);
+ } else if (postReply.getTime() < database.getFollowingTime(newSone.getId())) {
+ postReply.setKnown(true);
+ } else if (!postReply.isKnown()) {
+ events.add(new NewPostReplyFoundEvent(postReply));
+ }
+ }
+ for (PostReply postReply : soneComparison.getRemovedPostReplies()) {
+ events.add(new PostReplyRemovedEvent(postReply));
+ }
+ return events;
+ }
+