commit
45ea11ad15
|
@ -21,6 +21,9 @@
|
|||
</properties>
|
||||
<body>
|
||||
<release version="4.5" date="2020-MM-DD" description="Maintenance release.">
|
||||
<action issue="COLLECTIONS-737" dev="kinow" type="update" due-to="Prodigysov">
|
||||
Return 0 immeditaly if the given iterable is null in IterableUtils#size. Update tests.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-697" dev="eax" type="update" due-to="Ranjan George">
|
||||
JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented
|
||||
</action>
|
||||
|
|
|
@ -797,6 +797,9 @@ public class IterableUtils {
|
|||
* @return the number of elements contained in the iterable
|
||||
*/
|
||||
public static int size(final Iterable<?> iterable) {
|
||||
if (iterable == null) {
|
||||
return 0;
|
||||
}
|
||||
if (iterable instanceof Collection<?>) {
|
||||
return ((Collection<?>) iterable).size();
|
||||
}
|
||||
|
|
|
@ -416,12 +416,6 @@ public class FluentIterableTest {
|
|||
|
||||
@Test
|
||||
public void size() {
|
||||
try {
|
||||
FluentIterable.of((Iterable<?>) null).size();
|
||||
fail("expecting NullPointerException");
|
||||
} catch (final NullPointerException npe) {
|
||||
// expected
|
||||
}
|
||||
assertEquals(0, FluentIterable.of(emptyIterable).size());
|
||||
assertEquals(IterableUtils.toList(iterableOdd).size(), FluentIterable.of(iterableOdd).size());
|
||||
}
|
||||
|
|
|
@ -579,4 +579,9 @@ public class IterableUtilsTest {
|
|||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void size() {
|
||||
assertEquals(0, IterableUtils.size(null));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue