-
-
Save p4elkin/cbccff356553fd9b0a87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/magnolia-i18n/src/main/java/info/magnolia/i18nsystem/proxytoys/ChildDecorator.java b/magnolia-i18n/src/main/java/info/magnolia/i18nsystem/proxytoys/ChildDecorator.java | |
index 89cf82a..14e511f 100644 | |
--- a/magnolia-i18n/src/main/java/info/magnolia/i18nsystem/proxytoys/ChildDecorator.java | |
+++ b/magnolia-i18n/src/main/java/info/magnolia/i18nsystem/proxytoys/ChildDecorator.java | |
@@ -36,11 +36,13 @@ package info.magnolia.i18nsystem.proxytoys; | |
import java.lang.reflect.Method; | |
import java.util.Collection; | |
import java.util.List; | |
-import java.util.ListIterator; | |
import java.util.Map; | |
+import javax.annotation.Nullable; | |
+ | |
import com.google.common.base.Function; | |
import com.google.common.collect.Collections2; | |
+import com.google.common.collect.Lists; | |
import com.google.common.collect.Maps; | |
import com.thoughtworks.proxy.toys.decorate.Decorator; | |
@@ -66,13 +68,13 @@ class ChildDecorator<P> extends Decorator<P> { | |
} else if (result instanceof Collection) { | |
// We can't use Collections2.transform() or Lists.transform() as these create new immutable collections | |
if (result instanceof List) { | |
- // replace in-place | |
- final ListIterator listIterator = ((List) result).listIterator(); | |
- while (listIterator.hasNext()) { | |
- final Object child = listIterator.next(); | |
- listIterator.set(proxyCreator.decorateChild(child, parent)); | |
- } | |
- decoratedReturnValue = result; | |
+ decoratedReturnValue = Lists.transform(((List) result), new Function() { | |
+ @Nullable | |
+ @Override | |
+ public Object apply(@Nullable Object input) { | |
+ return proxyCreator.decorateChild(input, parent); | |
+ } | |
+ }); | |
} else { | |
// TODO - this is similar to the Map transformation above but still needs to be tested ! | |
decoratedReturnValue = Collections2.transform((Collection) result, new ChildDecoratorFunction(parent)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment