mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -643,7 +643,7 @@ public class IterUtil {
|
||||
*/
|
||||
public static Class<?> getElementType(Iterator<?> iterator) {
|
||||
final Iterator<?> iter2 = new CopiedIter<>(iterator);
|
||||
if (iter2.hasNext()) {
|
||||
while (iter2.hasNext()) {
|
||||
final Object t = iter2.next();
|
||||
if (null != t) {
|
||||
return t.getClass();
|
||||
|
@@ -90,6 +90,13 @@ public class IterUtilTest {
|
||||
Assert.assertEquals(expectedMap, testMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getElementTypeTest(){
|
||||
List<Integer> integers = Arrays.asList(null, 1);
|
||||
Class<?> elementType = IterUtil.getElementType(integers);
|
||||
Assert.assertEquals(Integer.class,elementType);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class Car {
|
||||
|
Reference in New Issue
Block a user