diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 1990c3798..393f1ee88 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -560,7 +560,7 @@ public class CollectionUtils { if (inputIterator != null && transformer != null) { while (inputIterator.hasNext()) { final I item = inputIterator.next(); - final O value = transformer.transform(item); + final O value = transformer.apply(item); outputCollection.add(value); } } @@ -2068,7 +2068,7 @@ public class CollectionUtils { if (collection instanceof List) { final List list = (List) collection; for (final ListIterator it = list.listIterator(); it.hasNext();) { - it.set(transformer.transform(it.next())); + it.set(transformer.apply(it.next())); } } else { final Collection resultCollection = collect(collection, transformer); diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java b/src/main/java/org/apache/commons/collections4/IteratorUtils.java index 856c4b857..10e244544 100644 --- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java +++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java @@ -1312,7 +1312,7 @@ public class IteratorUtils { if (iterator != null) { while (iterator.hasNext()) { final E element = iterator.next(); - stringBuilder.append(transformer.transform(element)); + stringBuilder.append(transformer.apply(element)); stringBuilder.append(delimiter); } if (stringBuilder.length() > prefix.length()) { diff --git a/src/main/java/org/apache/commons/collections4/MapUtils.java b/src/main/java/org/apache/commons/collections4/MapUtils.java index 9fa8a7a52..ccd4102ca 100644 --- a/src/main/java/org/apache/commons/collections4/MapUtils.java +++ b/src/main/java/org/apache/commons/collections4/MapUtils.java @@ -1497,7 +1497,7 @@ public class MapUtils { public static void populateMap(final Map map, final Iterable elements, final Transformer keyTransformer, final Transformer valueTransformer) { for (final E temp : elements) { - map.put(keyTransformer.transform(temp), valueTransformer.transform(temp)); + map.put(keyTransformer.apply(temp), valueTransformer.apply(temp)); } } @@ -1532,7 +1532,7 @@ public class MapUtils { public static void populateMap(final MultiMap map, final Iterable elements, final Transformer keyTransformer, final Transformer valueTransformer) { for (final E temp : elements) { - map.put(keyTransformer.transform(temp), valueTransformer.transform(temp)); + map.put(keyTransformer.apply(temp), valueTransformer.apply(temp)); } } diff --git a/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java b/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java index 883070e8c..ada438425 100644 --- a/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java @@ -65,7 +65,7 @@ public class TransformedBag extends TransformedCollection implements Bag extends TransformedBag implements Sorted final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics bag.clear(); for (final E value : values) { - decorated.decorated().add(transformer.transform(value)); + decorated.decorated().add(transformer.apply(value)); } } return decorated; diff --git a/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java b/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java index 1cab5556c..dec686f5f 100644 --- a/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java @@ -145,7 +145,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { * enforces a uniqueness constraint */ private void addToIndex(final C object) { - final K key = keyTransformer.transform(object); + final K key = keyTransformer.apply(object); if (uniqueIndex && index.containsKey(key)) { throw new IllegalArgumentException("Duplicate key in uniquely indexed collection."); } @@ -166,7 +166,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { @SuppressWarnings("unchecked") @Override public boolean contains(final Object object) { - return index.containsKey(keyTransformer.transform((C) object)); + return index.containsKey(keyTransformer.apply((C) object)); } /** @@ -236,7 +236,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { * @param object the object to remove */ private void removeFromIndex(final C object) { - index.remove(keyTransformer.transform(object)); + index.remove(keyTransformer.apply(object)); } /** diff --git a/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java b/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java index c30c591cd..456b33a53 100644 --- a/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java @@ -68,7 +68,7 @@ public class TransformedCollection extends AbstractCollectionDecorator { final E[] values = (E[]) collection.toArray(); // NOPMD - false positive for generics collection.clear(); for (final E value : values) { - decorated.decorated().add(transformer.transform(value)); + decorated.decorated().add(transformer.apply(value)); } } return decorated; @@ -146,7 +146,7 @@ public class TransformedCollection extends AbstractCollectionDecorator { * @return a transformed object */ protected E transform(final E object) { - return transformer.transform(object); + return transformer.apply(object); } } diff --git a/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java b/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java index fa873bb94..74adfdb7e 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java +++ b/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java @@ -81,8 +81,8 @@ public class TransformingComparator implements Comparator, Serializable */ @Override public int compare(final I obj1, final I obj2) { - final O value1 = this.transformer.transform(obj1); - final O value2 = this.transformer.transform(obj2); + final O value1 = this.transformer.apply(obj1); + final O value2 = this.transformer.apply(obj2); return this.decorated.compare(value1, value2); } diff --git a/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java index d2e21147c..444f5bf91 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java @@ -120,7 +120,7 @@ public class ChainedTransformer implements Transformer, Serializable { @Override public T transform(T object) { for (final Transformer iTransformer : iTransformers) { - object = iTransformer.transform(object); + object = iTransformer.apply(object); } return object; } diff --git a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java index ddf4a532a..787c43ae4 100644 --- a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java @@ -134,8 +134,8 @@ public class IfTransformer implements Transformer, Serializable { @Override public O transform(final I input) { if (iPredicate.test(input)) { - return iTrueTransformer.transform(input); + return iTrueTransformer.apply(input); } - return iFalseTransformer.transform(input); + return iFalseTransformer.apply(input); } } diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java index 395443952..eb3dbfa95 100644 --- a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java @@ -188,10 +188,10 @@ public class SwitchTransformer implements Transformer, Serializable public O transform(final I input) { for (int i = 0; i < iPredicates.length; i++) { if (iPredicates[i].test(input)) { - return iTransformers[i].transform(input); + return iTransformers[i].apply(input); } } - return iDefault.transform(input); + return iDefault.apply(input); } } diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java b/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java index 8fe496e12..7b19ce342 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java @@ -77,7 +77,7 @@ public final class TransformedPredicate extends AbstractPredicate implemen */ @Override public boolean test(final T object) { - final T result = iTransformer.transform(object); + final T result = iTransformer.apply(object); return iPredicate.test(result); } diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java b/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java index 8a528030f..6d47fde5a 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java @@ -69,7 +69,7 @@ public class TransformerClosure implements Closure, Serializable { */ @Override public void execute(final T input) { - iTransformer.transform(input); + iTransformer.apply(input); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java b/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java index ff5c796d9..e40b014d7 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java @@ -68,7 +68,7 @@ public final class TransformerPredicate extends AbstractPredicate implemen */ @Override public boolean test(final T object) { - final Boolean result = iTransformer.transform(object); + final Boolean result = iTransformer.apply(object); if (result == null) { throw new FunctorException( "Transformer must return an instanceof Boolean, it was a null object"); diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java index 0ec9a7c27..b094b4b47 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java @@ -160,7 +160,7 @@ public class ObjectGraphIterator implements Iterator { while (currentIterator.hasNext() && !hasNext) { E next = currentIterator.next(); if (transformer != null) { - next = transformer.transform(next); + next = transformer.apply(next); } findNext(next); } @@ -238,7 +238,7 @@ public class ObjectGraphIterator implements Iterator { if (transformer == null) { findNext(root); } else { - findNext(transformer.transform(root)); + findNext(transformer.apply(root)); } root = null; } diff --git a/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java b/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java index 668afc2f1..03f1a0209 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java @@ -133,6 +133,6 @@ public class TransformIterator implements Iterator { * @return the transformed object */ protected O transform(final I source) { - return transformer.transform(source); + return transformer.apply(source); } } diff --git a/src/main/java/org/apache/commons/collections4/list/LazyList.java b/src/main/java/org/apache/commons/collections4/list/LazyList.java index 3add8c96f..70ccd78d9 100644 --- a/src/main/java/org/apache/commons/collections4/list/LazyList.java +++ b/src/main/java/org/apache/commons/collections4/list/LazyList.java @@ -134,7 +134,7 @@ public class LazyList extends AbstractSerializableListDecorator { return factory.get(); } if (transformer != null) { - return transformer.transform(index); + return transformer.apply(index); } throw new IllegalStateException("Factory and Transformer are both null!"); } diff --git a/src/main/java/org/apache/commons/collections4/list/TransformedList.java b/src/main/java/org/apache/commons/collections4/list/TransformedList.java index b90505ad1..e1860fb3a 100644 --- a/src/main/java/org/apache/commons/collections4/list/TransformedList.java +++ b/src/main/java/org/apache/commons/collections4/list/TransformedList.java @@ -93,7 +93,7 @@ public class TransformedList extends TransformedCollection implements List final E[] values = (E[]) list.toArray(); // NOPMD - false positive for generics list.clear(); for (final E value : values) { - decorated.decorated().add(transformer.transform(value)); + decorated.decorated().add(transformer.apply(value)); } } return decorated; diff --git a/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java b/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java index a46d3c829..86fe2fa9c 100644 --- a/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java @@ -173,7 +173,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se final V v; return (v = map.get(key)) != null || map.containsKey(key) ? v - : value.transform((K) key); + : value.apply((K) key); } /** diff --git a/src/main/java/org/apache/commons/collections4/map/LazyMap.java b/src/main/java/org/apache/commons/collections4/map/LazyMap.java index 1577eb35b..24ad6432c 100644 --- a/src/main/java/org/apache/commons/collections4/map/LazyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/LazyMap.java @@ -135,7 +135,7 @@ public class LazyMap extends AbstractMapDecorator implements Seriali if (!map.containsKey(key)) { @SuppressWarnings("unchecked") final K castKey = (K) key; - final V value = factory.transform(castKey); + final V value = factory.apply(castKey); map.put(castKey, value); return value; } diff --git a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java index 607acd5e7..b80ce92f3 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java @@ -315,7 +315,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme * @return the new collection */ protected Collection createCollection(final int size) { - return collectionFactory.create(); + return collectionFactory.get(); } /** diff --git a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java index 80f165f7b..f7e1768f2 100644 --- a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java @@ -139,7 +139,7 @@ public class TransformedMap */ @Override protected V checkSetValue(final V value) { - return valueTransformer.transform(value); + return valueTransformer.apply(value); } /** @@ -192,7 +192,7 @@ public class TransformedMap if (keyTransformer == null) { return object; } - return keyTransformer.transform(object); + return keyTransformer.apply(object); } /** @@ -228,7 +228,7 @@ public class TransformedMap if (valueTransformer == null) { return object; } - return valueTransformer.transform(object); + return valueTransformer.apply(object); } /** diff --git a/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java index e0270c152..03174edae 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java @@ -167,7 +167,7 @@ public class TransformedMultiValuedMap extends AbstractMultiValuedMapDecor if (keyTransformer == null) { return object; } - return keyTransformer.transform(object); + return keyTransformer.apply(object); } /** @@ -182,7 +182,7 @@ public class TransformedMultiValuedMap extends AbstractMultiValuedMapDecor if (valueTransformer == null) { return object; } - return valueTransformer.transform(object); + return valueTransformer.apply(object); } } diff --git a/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java b/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java index 802ef3d17..f9583e0e3 100644 --- a/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java +++ b/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java @@ -62,7 +62,7 @@ public class TransformedQueue extends TransformedCollection implements Que final E[] values = (E[]) queue.toArray(); // NOPMD - false positive for generics queue.clear(); for (final E value : values) { - decorated.decorated().add(transformer.transform(value)); + decorated.decorated().add(transformer.apply(value)); } } return decorated; diff --git a/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java b/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java index df4c28fb4..02a05ba22 100644 --- a/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java +++ b/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java @@ -61,7 +61,7 @@ public class TransformedNavigableSet extends TransformedSortedSet implemen final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics set.clear(); for (final E value : values) { - decorated.decorated().add(transformer.transform(value)); + decorated.decorated().add(transformer.apply(value)); } } return decorated; diff --git a/src/main/java/org/apache/commons/collections4/set/TransformedSet.java b/src/main/java/org/apache/commons/collections4/set/TransformedSet.java index f217dfbd1..ed3846899 100644 --- a/src/main/java/org/apache/commons/collections4/set/TransformedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/TransformedSet.java @@ -63,7 +63,7 @@ public class TransformedSet extends TransformedCollection implements Set extends TransformedSet implements Sorted final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics set.clear(); for (final E value : values) { - decorated.decorated().add(transformer.transform(value)); + decorated.decorated().add(transformer.apply(value)); } } return decorated; diff --git a/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java index cc7f07dee..ea923178e 100644 --- a/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java +++ b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java @@ -124,7 +124,7 @@ public class TransformedSplitMap extends AbstractIterableGetMapDecor * @return the transformed value */ protected V checkSetValue(final U value) { - return valueTransformer.transform(value); + return valueTransformer.apply(value); } @Override @@ -165,7 +165,7 @@ public class TransformedSplitMap extends AbstractIterableGetMapDecor * @return the transformed object */ protected K transformKey(final J object) { - return keyTransformer.transform(object); + return keyTransformer.apply(object); } /** @@ -198,7 +198,7 @@ public class TransformedSplitMap extends AbstractIterableGetMapDecor * @return the transformed object */ protected V transformValue(final U object) { - return valueTransformer.transform(object); + return valueTransformer.apply(object); } /**