org.apache.commons.collections.iterators.ReverseListIterator Java Examples

The following examples show how to use org.apache.commons.collections.iterators.ReverseListIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReverseElementsInList.java    From levelup-java-examples with Apache License 2.0 6 votes vote down vote up
@Test 
public void reverse_elements_in_list_apache () {
	
	ReverseListIterator reverseListIterator = new ReverseListIterator(precipitation);
	
	List<String> reversePrecipitation = new ArrayList<String>();
	while (reverseListIterator.hasNext()) {
		reversePrecipitation.add( (String) reverseListIterator.next());
	}
	
	assertThat(reversePrecipitation, contains(
			 "Drizzle", "Rain", "Freezing rain", 
			 "Freezing drizzle", "Ice crystals", 
			 "Hail", "Ice pellets", 
			 "Snow grains", "Snow"));
}
 
Example #2
Source File: List.java    From sling-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the children.
 * 
 * <p>Get the children, convert them to a Java List, reverse them, 
 * and adapt the collection to a Post model</p>
 * 
 * @return the children
 */
@SuppressWarnings("unchecked")
public Iterator<Post> getChildren() {
    if(this.resource != null) {
        java.util.List<Resource> childrenList = IteratorUtils.toList(this.resource.getChildren().iterator());
        Iterator<Resource> reverseChildren = new ReverseListIterator(childrenList);
        return ResourceUtil.adaptTo(reverseChildren, Post.class);
    } else {
        return null;
    }
}
 
Example #3
Source File: CaseResult.java    From junit-plugin with MIT License 5 votes vote down vote up
private String getNameWithEnclosingBlocks(String rawName) {
    // Only prepend the enclosing flow node names if there are any and the run this is in has multiple blocks directly containing
    // test results.
    if (!getEnclosingFlowNodeNames().isEmpty()) {
        Run<?, ?> r = getRun();
        if (r != null) {
            TestResultAction action = r.getAction(TestResultAction.class);
            if (action != null && action.getResult().hasMultipleBlocks()) {
                return StringUtils.join(new ReverseListIterator(getEnclosingFlowNodeNames()), " / ") + " / " + rawName;
            }
        }
    }
    return rawName;
}
 
Example #4
Source File: Main.java    From softwarecave with GNU General Public License v3.0 5 votes vote down vote up
private static void iterateReverseListIterator(List<String> list) {
    System.out.print("\nApache ReverseListIterator:\n");
    Iterator<String> it = new ReverseListIterator(list);
    while (it.hasNext()) {
        System.out.println(it.next());
    }
}