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

The following examples show how to use org.apache.commons.collections4.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: ComponentsHelper.java    From cuba with Apache License 2.0 6 votes vote down vote up
public static String getFullFrameId(Frame frame) {
    if (frame instanceof Window) {
        return frame.getId();
    }

    List<String> frameIds = new ArrayList<>(4);
    frameIds.add(frame.getId());
    while (frame != null && !(frame instanceof Window) && frame != frame.getFrame()) {
        frame = frame.getFrame();
        if (frame != null) {
            frameIds.add(frame.getId());
        }
    }

    return StringUtils.join(new ReverseListIterator<>(frameIds), '.');
}
 
Example #2
Source File: ReverseIterator.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Iterate using Apache Commons {@link ReverseListIterator}.
 *
 * @param list the list
 */
public void iterateUsingApacheReverseListIterator(final List<String> list) {

    final ReverseListIterator listIterator = new ReverseListIterator(list);
    while (listIterator.hasNext()) {
        System.out.println(listIterator.next());
    }
}
 
Example #3
Source File: ReverseIteratorUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
void whenIteratingUsingApacheReverseListIterator_thenCorrect() {

    String reverseString = "";
    final ReverseListIterator listIterator = new ReverseListIterator(list);
    while (listIterator.hasNext()) {
        reverseString += listIterator.next();
    }
    assertEquals(reverseString, StringUtils.reverse(originalString));
}