win.doyto.query.service.CollectionUtil Maven / Gradle / Ivy
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());
}
}
}
}