public long recalculateChildCount() { // Reset the child count childCount = 0; if (hasChildren()) { for (TreeFacetField childNode : hierarchy) { childCount += childNode.recalculateChildCount(); } } return getTotal(); }
private SortedSet<TreeFacetField> cloneHierarchy(SortedSet<TreeFacetField> orig) { SortedSet<TreeFacetField> cloned = null; if (orig != null) { cloned = new TreeSet<>(orig.comparator()); for (TreeFacetField tff : orig) { cloned.add(tff.clone()); } } return cloned; }
@Override public int compareTo(TreeFacetField o) { int ret = 0; if (o == null) { ret = 1; } else { ret = (int) (getTotal() - o.getTotal()); if (ret == 0) { // If the totals are the same, compare the count as well. ret = (int) (count - o.count); if (ret == 0) { // If the counts are also the same, compare the ID as well, to double-check // whether they're actually the same entry ret = getValue().compareTo(o.getValue()); } } } return ret; }