Use Collection.isEmpty() instead of size() == 0

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1199983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2011-11-09 21:41:24 +00:00
parent 371e866442
commit 1460653475
2 changed files with 3 additions and 3 deletions

View File

@ -296,7 +296,7 @@ public class Validate {
if (collection == null) { if (collection == null) {
throw new NullPointerException(String.format(message, values)); throw new NullPointerException(String.format(message, values));
} }
if (collection.size() == 0) { if (collection.isEmpty()) {
throw new IllegalArgumentException(String.format(message, values)); throw new IllegalArgumentException(String.format(message, values));
} }
return collection; return collection;
@ -345,7 +345,7 @@ public class Validate {
if (map == null) { if (map == null) {
throw new NullPointerException(String.format(message, values)); throw new NullPointerException(String.format(message, values));
} }
if (map.size() == 0) { if (map.isEmpty()) {
throw new IllegalArgumentException(String.format(message, values)); throw new IllegalArgumentException(String.format(message, values));
} }
return map; return map;

View File

@ -522,7 +522,7 @@ public class ExtendedMessageFormat extends MessageFormat {
* @return <code>true</code> if some Object was found, <code>false</code> otherwise. * @return <code>true</code> if some Object was found, <code>false</code> otherwise.
*/ */
private boolean containsElements(Collection<?> coll) { private boolean containsElements(Collection<?> coll) {
if (coll == null || coll.size() == 0) { if (coll == null || coll.isEmpty()) {
return false; return false;
} }
for (Object name : coll) { for (Object name : coll) {