All Downloads are FREE. Search and download functionalities are using the official Maven repository.

win.doyto.query.service.CollectionUtil Maven / Gradle / Ivy

There is a newer version: 0.2.2.1-RELEASE
Show newest version
package win.doyto.query.service;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.Iterator;

/**
 * CollectionUtil
 *
 * @author f0rb
 */
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
class CollectionUtil {
    public static  E first(Iterable iterable) {
        Iterator iterator = iterable.iterator();
        try {
            return iterator.hasNext() ? iterator.next() : null;
        } finally {
            if (iterator.hasNext()) {
                log.warn("Find more than one element of {}", iterator.next().getClass());
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy