summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools/ant/util/CollectionUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/org/apache/tools/ant/util/CollectionUtils.java')
-rw-r--r--src/main/org/apache/tools/ant/util/CollectionUtils.java31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/main/org/apache/tools/ant/util/CollectionUtils.java b/src/main/org/apache/tools/ant/util/CollectionUtils.java
index 94fa92801..c516fe324 100644
--- a/src/main/org/apache/tools/ant/util/CollectionUtils.java
+++ b/src/main/org/apache/tools/ant/util/CollectionUtils.java
@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
*
* @since Ant 1.5
*/
+@Deprecated
public class CollectionUtils {
@SuppressWarnings("rawtypes")
@@ -80,20 +81,10 @@ public class CollectionUtils {
return false;
}
- Enumeration<?> e1 = d1.keys();
- while (e1.hasMoreElements()) {
- Object key = e1.nextElement();
- Object value1 = d1.get(key);
- Object value2 = d2.get(key);
- if (!value1.equals(value2)) {
- return false;
- }
- }
-
// don't need the opposite check as the Dictionaries have the
// same size, so we've also covered all keys of d2 already.
-
- return true;
+ return Collections.list(d1.keys()).stream()
+ .allMatch(key -> d1.get(key).equals(d2.get(key)));
}
/**
@@ -103,7 +94,9 @@ public class CollectionUtils {
* @param c collection to transform
* @return string representation of the collection
* @since Ant 1.8.0
+ * @deprecated use stream().collect(Collectors.joining(","))
*/
+ @Deprecated
public static String flattenToString(Collection<?> c) {
return c.stream().map(String::valueOf).collect(Collectors.joining(","));
}
@@ -120,10 +113,7 @@ public class CollectionUtils {
@Deprecated
public static <K, V> void putAll(Dictionary<? super K, ? super V> m1,
Dictionary<? extends K, ? extends V> m2) {
- for (Enumeration<? extends K> it = m2.keys(); it.hasMoreElements();) {
- K key = it.nextElement();
- m1.put(key, m2.get(key));
- }
+ Collections.list(m2.keys()).forEach(key -> m1.put(key, m2.get(key)));
}
/**
@@ -159,7 +149,10 @@ public class CollectionUtils {
* @param <E> element type
* @return an enumeration representing e1 followed by e2.
* @since Ant 1.6.3
+ * @deprecated use Stream.concat(Collections.list(e1).stream(), Collections.list(e2).stream())
+ * .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration))
*/
+ @Deprecated
public static <E> Enumeration<E> append(Enumeration<E> e1, Enumeration<E> e2) {
return new CompoundEnumeration<>(e1, e2);
}
@@ -169,7 +162,9 @@ public class CollectionUtils {
* @param iter the Iterator to adapt.
* @param <E> element type
* @return an Enumeration.
+ * @deprecated use Collections.enumeration()
*/
+ @Deprecated
public static <E> Enumeration<E> asEnumeration(final Iterator<E> iter) {
return new Enumeration<E>() {
@Override
@@ -188,7 +183,9 @@ public class CollectionUtils {
* @param e the Enumeration to adapt.
* @param <E> element type
* @return an Iterator.
+ * @deprecated use Collections.list(e).iterator()
*/
+ @Deprecated
public static <E> Iterator<E> asIterator(final Enumeration<E> e) {
return new Iterator<E>() {
@Override
@@ -213,7 +210,9 @@ public class CollectionUtils {
* @param <T> element type
* @return the collection
* @since Ant 1.8.0
+ * @deprecated instantiate a list an use forEachRemaining(list::add)
*/
+ @Deprecated
public static <T> Collection<T> asCollection(final Iterator<? extends T> iter) {
List<T> l = new ArrayList<>();
iter.forEachRemaining(l::add);