CollectionTool extends org.apache.velocity.tools.generic.CollectionTool { public <E extends Comparable<E>> boolean sortModifiable(List<E> input) { if (input == null) { return false; } try { Collections.sort(input); return true; } catch (UnsupportedOperationException ex) { return false; } }  List<E> getArrayList(); List<E> getLinkedList(); Map<K, V> getMap(); SortedMap<K, V> getSortedMap(); Map<K, V> getOrderedMap(); Set<E> getSet(); SortedSet<E> getSortedSet(); Set<E> getOrderedSet(); Queue<E> getQueue(); BlockingQueue<E> getBlockingQueue(); Queue<E> getPriorityQueue(); List<E> unmodifiable(List<E> input); Map<K, V> unmodifiable(Map<K, V> input); Set<E> unmodifiable(Set<E> input); Collection<E> unmodifiable(Collection<E> input); Collection<E> union(Collection<E> a, Collection<E> b); Collection<E> intersection(Collection<E> a, Collection<E> b); Collection<E> disjunction(Collection<E> a, Collection<E> b); boolean reverseModifiable(List<E> input); boolean sortModifiable(List<E> input);  }
@Test void testSortModifiable() { List<String> list = this.tool.getLinkedList(); list.add("one"); list.add("two"); list.add("three"); assertTrue(this.tool.sortModifiable(list), "Failed to sort the list"); assertEquals("one", list.get(0), "List wasn't properly sorted"); assertEquals("three", list.get(1), "List wasn't properly sorted"); assertEquals("two", list.get(2), "List wasn't properly sorted"); this.tool.reverseModifiable(list); List<String> readonly = this.tool.unmodifiable(list); assertFalse(this.tool.sortModifiable(readonly), "Unmodifiable list wrongly sorted"); assertEquals("two", list.get(0), "Unmodifiable list was changed"); list = null; assertFalse(this.tool.sortModifiable(list), "Sorted a null list?"); }