diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 1990c3798d..393f1ee88a 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 static > R collect(final Iterator void transform(final Collection collection, 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 856c4b8572..10e244544d 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 static String toString(final Iterator iterator, 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 9fa8a7a52f..ccd4102cad 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 static OrderedMap orderedMap(final Map map) { 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 static void populateMap(final Map map, final Iterable 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 883070e8c8..ada438425c 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 static Bag transformedBag(final Bag bag, final Transformer TransformedSortedBag transformedSortedBag(final SortedBag coll) { * 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 void clear() { @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 boolean removeAll(final Collection coll) { * @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 c30c591cdc..456b33a53e 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 static TransformedCollection transformedCollection(final Collectio 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 @@ protected Collection transform(final Collection coll) { * @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 fa873bb94d..74adfdb7e9 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 TransformingComparator(final Transformer transfor */ @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 d2e21147c0..444f5bf919 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 ChainedTransformer(final Transformer... transform @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 ddf4a532a2..787c43ae46 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 Predicate getPredicate() { @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 3954439525..eb3dbfa959 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 Predicate[] getPredicates() { 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 8fe496e127..7b19ce342e 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 TransformedPredicate(final Transformer transforme */ @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 8a528030ff..6d47fde5a5 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 TransformerClosure(final Transformer transformer) { */ @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 ff5c796d97..e40b014d77 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 TransformerPredicate(final Transformer transformer) { */ @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 0ec9a7c276..b094b4b477 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 @@ protected void findNextByIterator(final Iterator 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 @@ protected void updateCurrentIterator() { 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 668afc2f19..03f1a02099 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 void setTransformer(final Transformer transformer * @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 3add8c96f3..70ccd78d9d 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 @@ private E element(final int index) { 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 b90505ad1f..e1860fb3a4 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 static TransformedList transformedList(final List 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 a46d3c829c..86fe2fa9ce 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 V get(final Object key) { 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 1577eb35b2..24ad6432c5 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 V get(final Object key) { 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 607acd5e76..b80ce92f32 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 boolean containsValue(final Object key, final Object value) { * @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 80f165f7b7..f7e1768f2d 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 @@ protected TransformedMap(final Map map, final Transformer TransformedQueue transformedQueue(final Queue queue, 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 df4c28fb49..02a05ba22a 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 static TransformedNavigableSet transformedNavigableSet(final Navig 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 f217dfbd13..ed38468998 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 static Set transformedSet(final Set set, final Transformer TransformedSortedSet transformedSortedSet(final SortedSet map, final Transformer transformMap(final Map map) { * @return the transformed object */ protected V transformValue(final U object) { - return valueTransformer.transform(object); + return valueTransformer.apply(object); } /**