1
1
/*
2
- * Copyright 2002-2016 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -125,7 +125,7 @@ public static <K, V> void mergePropertiesIntoMap(Properties props, Map<K, V> map
125
125
* Check whether the given Iterator contains the given element.
126
126
* @param iterator the Iterator to check
127
127
* @param element the element to look for
128
- * @return {@code true} if found, {@code false} else
128
+ * @return {@code true} if found, {@code false} otherwise
129
129
*/
130
130
public static boolean contains (Iterator <?> iterator , Object element ) {
131
131
if (iterator != null ) {
@@ -143,7 +143,7 @@ public static boolean contains(Iterator<?> iterator, Object element) {
143
143
* Check whether the given Enumeration contains the given element.
144
144
* @param enumeration the Enumeration to check
145
145
* @param element the element to look for
146
- * @return {@code true} if found, {@code false} else
146
+ * @return {@code true} if found, {@code false} otherwise
147
147
*/
148
148
public static boolean contains (Enumeration <?> enumeration , Object element ) {
149
149
if (enumeration != null ) {
@@ -163,7 +163,7 @@ public static boolean contains(Enumeration<?> enumeration, Object element) {
163
163
* {@code true} for an equal element as well.
164
164
* @param collection the Collection to check
165
165
* @param element the element to look for
166
- * @return {@code true} if found, {@code false} else
166
+ * @return {@code true} if found, {@code false} otherwise
167
167
*/
168
168
public static boolean containsInstance (Collection <?> collection , Object element ) {
169
169
if (collection != null ) {
@@ -268,7 +268,7 @@ public static Object findValueOfType(Collection<?> collection, Class<?>[] types)
268
268
* Determine whether the given Collection only contains a single unique object.
269
269
* @param collection the Collection to check
270
270
* @return {@code true} if the collection contains a single reference or
271
- * multiple references to the same instance, {@code false} else
271
+ * multiple references to the same instance, {@code false} otherwise
272
272
*/
273
273
public static boolean hasUniqueObject (Collection <?> collection ) {
274
274
if (isEmpty (collection )) {
@@ -326,12 +326,13 @@ public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array
326
326
}
327
327
328
328
/**
329
- * Adapt an enumeration to an iterator .
330
- * @param enumeration the enumeration
331
- * @return the iterator
329
+ * Adapt an {@link Enumeration} to an {@link Iterator} .
330
+ * @param enumeration the original {@code Enumeration}
331
+ * @return the adapted {@code Iterator}
332
332
*/
333
+ @ SuppressWarnings ("unchecked" )
333
334
public static <E > Iterator <E > toIterator (Enumeration <E > enumeration ) {
334
- return new EnumerationIterator <E >(enumeration );
335
+ return ( enumeration != null ? new EnumerationIterator <E >(enumeration ) : Collections . EMPTY_SET . iterator () );
335
336
}
336
337
337
338
/**
@@ -508,7 +509,7 @@ public boolean equals(Object other) {
508
509
if (this == other ) {
509
510
return true ;
510
511
}
511
- return map .equals (other );
512
+ return this . map .equals (other );
512
513
}
513
514
514
515
@ Override
0 commit comments