@Test(expected = CycleDetectedException.class) public void sortFromLeafToRootWithLoopShouldThrow() { Mailbox a = Mailbox.builder().name("A").id(A_ID).parentId(B_ID).build(); Mailbox b = Mailbox.builder().name("B").id(B_ID).parentId(A_ID).build(); ImmutableList<Mailbox> input = ImmutableList.of(a, b); sut.sortFromLeafToRoot(input); }
public List<T> sortFromLeafToRoot(Collection<T> elements) throws CycleDetectedException { return Lists.reverse(sortFromRootToLeaf(elements)); }
SortingHierarchicalCollections { public List<T> sortFromLeafToRoot(Collection<T> elements) throws CycleDetectedException { return Lists.reverse(sortFromRootToLeaf(elements)); } }
SortingHierarchicalCollections { public List<T> sortFromLeafToRoot(Collection<T> elements) throws CycleDetectedException { return Lists.reverse(sortFromRootToLeaf(elements)); } SortingHierarchicalCollections(Function<T, IdT> index,
                                  Function<T, Optional<IdT>> parentId); }
SortingHierarchicalCollections { public List<T> sortFromLeafToRoot(Collection<T> elements) throws CycleDetectedException { return Lists.reverse(sortFromRootToLeaf(elements)); } SortingHierarchicalCollections(Function<T, IdT> index,
                                  Function<T, Optional<IdT>> parentId); List<T> sortFromRootToLeaf(Collection<T> elements); List<T> sortFromLeafToRoot(Collection<T> elements); }
SortingHierarchicalCollections { public List<T> sortFromLeafToRoot(Collection<T> elements) throws CycleDetectedException { return Lists.reverse(sortFromRootToLeaf(elements)); } SortingHierarchicalCollections(Function<T, IdT> index,
                                  Function<T, Optional<IdT>> parentId); List<T> sortFromRootToLeaf(Collection<T> elements); List<T> sortFromLeafToRoot(Collection<T> elements);  }