/** * Returns the previous topic for the topic given. * This method is sorting aware, i. e. all the sorting applied * in topic selection query will be be taken into account. * * @param topic a topic to found predecessor for * @return previous topic or null, if the argument is the first topic in the branch */ public Topic getPreviousTopic(Topic topic) { int index = this.getTopicIndexInList(topic); if (index == 0) { return null; } else { return topics.get(index - 1); } }
/** * Returns the next topic for the topic given. * This method is sorting aware, i. e. all the sorting applied * in topic selection query will be taken into account. * * @param topic a topic to found the next one for * @return next topic or null, if the argument is the last topic in the branch */ public Topic getNextTopic(Topic topic) { int index = this.getTopicIndexInList(topic); if (index == topics.size() - 1) { return null; } else { return topics.get(index + 1); } }