Example usage for java.util AbstractList isEmpty

List of usage examples for java.util AbstractList isEmpty

Introduction

In this page you can find the example usage for java.util AbstractList isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:com.oltpbenchmark.util.CollectionUtil.java

/**
 * Return the last item in an Iterable//from  w  w  w  . jav a2s.c om
 * @param <T>
 * @param items
 * @return
 */
public static <T> T last(Iterable<T> items) {
    T last = null;
    if (items instanceof AbstractList<?>) {
        AbstractList<T> list = (AbstractList<T>) items;
        last = (list.isEmpty() ? null : list.get(list.size() - 1));
    } else {
        for (T t : items) {
            last = t;
        }
    }
    return (last);
}