This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new bc8bc7aa45 GROOVY-11911: Deprecate callsite versions of
BooleanClosureWrapper
bc8bc7aa45 is described below
commit bc8bc7aa451f1557febddb5027df2851fcbdf265
Author: Paul King <[email protected]>
AuthorDate: Tue Apr 7 14:50:56 2026 +1000
GROOVY-11911: Deprecate callsite versions of BooleanClosureWrapper
---
src/main/java/groovy/lang/Closure.java | 2 +-
.../groovy/runtime/ArrayGroovyMethods.java | 9 +++---
.../BooleanClosureForMapPredicate.java | 31 +++++++------------
...yCallSite.java => BooleanClosurePredicate.java} | 25 ++++++++++++---
...apPredicate.java => BooleanClosureWrapper.java} | 36 +++++++++++++---------
.../groovy/runtime/DefaultGroovyMethods.java | 19 +++++-------
.../codehaus/groovy/runtime/IOGroovyMethods.java | 2 +-
.../groovy/runtime/ResourceGroovyMethods.java | 4 +--
.../callsite/BooleanClosureForMapPredicate.java | 19 +++---------
.../runtime/callsite/BooleanClosurePredicate.java | 6 ++--
.../runtime/callsite/BooleanClosureWrapper.java | 9 ++++--
.../callsite/BooleanReturningMethodInvoker.java | 1 +
.../groovy/nio/extensions/NioExtensions.java | 4 +--
13 files changed, 83 insertions(+), 84 deletions(-)
diff --git a/src/main/java/groovy/lang/Closure.java
b/src/main/java/groovy/lang/Closure.java
index 0071e95389..71e90aa756 100644
--- a/src/main/java/groovy/lang/Closure.java
+++ b/src/main/java/groovy/lang/Closure.java
@@ -28,7 +28,7 @@ import org.codehaus.groovy.runtime.CurriedClosure;
import org.codehaus.groovy.runtime.GeneratedClosure;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.codehaus.groovy.runtime.InvokerInvocationException;
-import org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper;
+import org.codehaus.groovy.runtime.BooleanClosureWrapper;
import org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache;
import org.codehaus.groovy.runtime.memoize.ConcurrentSoftCache;
import org.codehaus.groovy.runtime.memoize.LRUCache;
diff --git a/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
index 24f1a17e04..15690cfd2c 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
@@ -38,10 +38,10 @@ import groovy.util.function.FloatUnaryOperator;
import groovy.util.function.IntComparator;
import groovy.util.function.LongComparator;
import org.apache.groovy.lang.annotation.Incubating;
-import org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper;
-import org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker;
-import org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv;
+import org.codehaus.groovy.runtime.BooleanClosureWrapper;
import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
+import org.codehaus.groovy.runtime.InvokerHelper;
+import org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv;
import org.codehaus.groovy.util.ArrayIterable;
import org.codehaus.groovy.util.ArrayIterator;
import org.codehaus.groovy.util.BooleanArrayIterator;
@@ -4319,9 +4319,8 @@ public class ArrayGroovyMethods extends
DefaultGroovyMethodsSupport {
*/
public static <T> List<T> grep(T[] self, Object filter) {
List<T> answer = new ArrayList<>();
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker("isCase");
for (T element : self) {
- if (bmi.invoke(filter, element)) {
+ if
(DefaultTypeTransformation.castToBoolean(InvokerHelper.invokeMethod(filter,
"isCase", element))) {
answer.add(element);
}
}
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
b/src/main/java/org/codehaus/groovy/runtime/BooleanClosureForMapPredicate.java
similarity index 58%
copy from
src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
copy to
src/main/java/org/codehaus/groovy/runtime/BooleanClosureForMapPredicate.java
index 5d97a06b04..a5dfe8eb7d 100644
---
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
+++
b/src/main/java/org/codehaus/groovy/runtime/BooleanClosureForMapPredicate.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.codehaus.groovy.runtime.callsite;
+package org.codehaus.groovy.runtime;
import groovy.lang.Closure;
@@ -24,36 +24,27 @@ import java.util.Map;
import java.util.function.Predicate;
/**
- * Helper class for internal use only.
- * This creates a Predicate by calling a {@link Closure} and converting the
result to a boolean.
- * {@link BooleanReturningMethodInvoker} is used for caching.
+ * Adapts a {@link Closure} to a {@link Predicate} over {@link Map.Entry}
values.
+ * If the closure takes two parameters, the key and value are passed
separately;
+ * otherwise the {@link Map.Entry} itself is passed.
+ *
+ * @since 6.0.0
*/
public class BooleanClosureForMapPredicate<K, V> implements
Predicate<Map.Entry<K, V>> {
- private final BooleanReturningMethodInvoker bmi;
- private final Closure wrapped;
+ private final BooleanClosureWrapper bcw;
private final int numberOfArguments;
public BooleanClosureForMapPredicate(Closure wrapped) {
- this.wrapped = wrapped;
- bmi = new BooleanReturningMethodInvoker("call");
- numberOfArguments = wrapped.getMaximumNumberOfParameters();
- }
-
- private boolean call(Object... args) {
- return bmi.invoke(wrapped, args);
+ this.bcw = new BooleanClosureWrapper(wrapped);
+ this.numberOfArguments = wrapped.getMaximumNumberOfParameters();
}
- /**
- * If the call to the backing {@link Closure} is done on a {@link Closure}
- * taking one argument, then we give in the {@link Map.Entry}, otherwise
we will
- * give in the key and value.
- */
@Override
public boolean test(Map.Entry<K, V> entry) {
if (numberOfArguments == 2) {
- return call(entry.getKey(), entry.getValue());
+ return bcw.call(entry.getKey(), entry.getValue());
} else {
- return call(entry);
+ return bcw.call(entry);
}
}
}
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/DummyCallSite.java
b/src/main/java/org/codehaus/groovy/runtime/BooleanClosurePredicate.java
similarity index 59%
rename from
src/main/java/org/codehaus/groovy/runtime/callsite/DummyCallSite.java
rename to src/main/java/org/codehaus/groovy/runtime/BooleanClosurePredicate.java
index 584de05ef0..d5f1230159 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/DummyCallSite.java
+++ b/src/main/java/org/codehaus/groovy/runtime/BooleanClosurePredicate.java
@@ -16,10 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.codehaus.groovy.runtime.callsite;
+package org.codehaus.groovy.runtime;
-public class DummyCallSite extends AbstractCallSite {
- public DummyCallSite(CallSiteArray array, int index, String name) {
- super(array, index,name);
+import groovy.lang.Closure;
+
+import java.util.function.Predicate;
+
+/**
+ * Adapts a {@link Closure} to a {@link Predicate}, converting the closure's
+ * return value to a boolean using Groovy truth semantics.
+ *
+ * @since 6.0.0
+ */
+public class BooleanClosurePredicate<T> implements Predicate<T> {
+ private final BooleanClosureWrapper bcw;
+
+ public BooleanClosurePredicate(Closure wrapped) {
+ this.bcw = new BooleanClosureWrapper(wrapped);
+ }
+
+ @Override
+ public boolean test(T arg) {
+ return bcw.call(arg);
}
}
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
b/src/main/java/org/codehaus/groovy/runtime/BooleanClosureWrapper.java
similarity index 56%
copy from
src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
copy to src/main/java/org/codehaus/groovy/runtime/BooleanClosureWrapper.java
index 5d97a06b04..4fa46809d1 100644
---
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
+++ b/src/main/java/org/codehaus/groovy/runtime/BooleanClosureWrapper.java
@@ -16,40 +16,46 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.codehaus.groovy.runtime.callsite;
+package org.codehaus.groovy.runtime;
import groovy.lang.Closure;
+import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
import java.util.Map;
-import java.util.function.Predicate;
/**
- * Helper class for internal use only.
- * This creates a Predicate by calling a {@link Closure} and converting the
result to a boolean.
- * {@link BooleanReturningMethodInvoker} is used for caching.
+ * Helper class for internal use only. This allows calling a {@link Closure}
and
+ * converting the result to a boolean using Groovy truth semantics:
+ * null returns false, Boolean is unboxed, and for other types
+ * {@code asBoolean()} is called.
+ *
+ * @since 6.0.0
*/
-public class BooleanClosureForMapPredicate<K, V> implements
Predicate<Map.Entry<K, V>> {
- private final BooleanReturningMethodInvoker bmi;
+public class BooleanClosureWrapper {
private final Closure wrapped;
private final int numberOfArguments;
- public BooleanClosureForMapPredicate(Closure wrapped) {
+ public BooleanClosureWrapper(Closure wrapped) {
this.wrapped = wrapped;
- bmi = new BooleanReturningMethodInvoker("call");
- numberOfArguments = wrapped.getMaximumNumberOfParameters();
+ this.numberOfArguments = wrapped.getMaximumNumberOfParameters();
}
- private boolean call(Object... args) {
- return bmi.invoke(wrapped, args);
+ /**
+ * Normal closure call with boolean conversion.
+ */
+ public boolean call(Object... args) {
+ Object result = wrapped.call(args);
+ if (result == null) return false;
+ if (result instanceof Boolean) return (Boolean) result;
+ return DefaultTypeTransformation.castToBoolean(result);
}
/**
- * If the call to the backing {@link Closure} is done on a {@link Closure}
+ * Bridge for a call based on a map entry. If the call is done on a {@link
Closure}
* taking one argument, then we give in the {@link Map.Entry}, otherwise
we will
* give in the key and value.
*/
- @Override
- public boolean test(Map.Entry<K, V> entry) {
+ public <K, V> boolean callForMap(Map.Entry<K, V> entry) {
if (numberOfArguments == 2) {
return call(entry.getKey(), entry.getValue());
} else {
diff --git
a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index b214482c9e..2066135cbf 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -63,10 +63,9 @@ import org.codehaus.groovy.reflection.ClassInfo;
import org.codehaus.groovy.reflection.MixinInMetaClass;
import org.codehaus.groovy.reflection.ReflectionUtils;
import org.codehaus.groovy.reflection.stdclasses.CachedSAMClass;
-import org.codehaus.groovy.runtime.callsite.BooleanClosureForMapPredicate;
-import org.codehaus.groovy.runtime.callsite.BooleanClosurePredicate;
-import org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper;
-import org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker;
+import org.codehaus.groovy.runtime.BooleanClosureForMapPredicate;
+import org.codehaus.groovy.runtime.BooleanClosurePredicate;
+import org.codehaus.groovy.runtime.BooleanClosureWrapper;
import org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv;
import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus;
import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply;
@@ -574,9 +573,8 @@ public class DefaultGroovyMethods extends
DefaultGroovyMethodsSupport {
* @since 1.5.0
*/
public static boolean any(Object self) {
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker();
for (var iter = InvokerHelper.asIterator(self); iter.hasNext(); ) {
- if (bmi.convertToBoolean(iter.next())) {
+ if (DefaultTypeTransformation.castToBoolean(iter.next())) {
return true;
}
}
@@ -5301,9 +5299,8 @@ public class DefaultGroovyMethods extends
DefaultGroovyMethodsSupport {
* @since 1.5.0
*/
public static boolean every(Object self) {
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker();
for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext(); )
{
- if (!bmi.convertToBoolean(iter.next())) {
+ if (!DefaultTypeTransformation.castToBoolean(iter.next())) {
return false;
}
}
@@ -7578,10 +7575,9 @@ public class DefaultGroovyMethods extends
DefaultGroovyMethodsSupport {
@SuppressWarnings("unchecked")
public static Collection grep(Object self, Object filter) {
Collection answer = createSimilarOrDefaultCollection(self);
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker("isCase");
for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) {
Object object = iter.next();
- if (bmi.invoke(filter, object)) {
+ if
(DefaultTypeTransformation.castToBoolean(InvokerHelper.invokeMethod(filter,
"isCase", object))) {
answer.add(object);
}
}
@@ -7609,9 +7605,8 @@ public class DefaultGroovyMethods extends
DefaultGroovyMethodsSupport {
*/
public static <T> Collection<T> grep(Collection<T> self, Object filter) {
Collection<T> answer = createSimilarCollection(self);
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker("isCase");
for (T element : self) {
- if (bmi.invoke(filter, element)) {
+ if
(DefaultTypeTransformation.castToBoolean(InvokerHelper.invokeMethod(filter,
"isCase", element))) {
answer.add(element);
}
}
diff --git a/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java
index de8448d915..7875ec11c7 100644
--- a/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java
@@ -28,7 +28,7 @@ import groovy.transform.stc.FromString;
import groovy.transform.stc.PickFirstResolver;
import groovy.transform.stc.SimpleType;
import org.apache.groovy.io.StringBuilderWriter;
-import org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper;
+import org.codehaus.groovy.runtime.BooleanClosureWrapper;
import java.io.BufferedReader;
import java.io.BufferedWriter;
diff --git
a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
index be5b8d97cb..9faf00bf27 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
@@ -31,7 +31,6 @@ import groovy.transform.stc.FromString;
import groovy.transform.stc.PickFirstResolver;
import groovy.transform.stc.SimpleType;
import groovy.util.CharsetToolkit;
-import org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker;
import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
import java.io.BufferedInputStream;
@@ -1651,12 +1650,11 @@ public class ResourceGroovyMethods extends
DefaultGroovyMethodsSupport {
final File[] files = self.listFiles();
// null check because of
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4803836
if (files == null) return;
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker("isCase");
for (final File currentFile : files) {
if (fileType == FileType.ANY ||
(fileType != FileType.FILES && currentFile.isDirectory())
||
(fileType != FileType.DIRECTORIES &&
currentFile.isFile())) {
- if (bmi.invoke(nameFilter, currentFile.getName()))
+ if
(DefaultTypeTransformation.castToBoolean(InvokerHelper.invokeMethod(nameFilter,
"isCase", currentFile.getName())))
closure.call(currentFile);
}
}
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
index 5d97a06b04..7661d82a66 100644
---
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
+++
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureForMapPredicate.java
@@ -24,10 +24,10 @@ import java.util.Map;
import java.util.function.Predicate;
/**
- * Helper class for internal use only.
- * This creates a Predicate by calling a {@link Closure} and converting the
result to a boolean.
- * {@link BooleanReturningMethodInvoker} is used for caching.
+ * @deprecated Use {@link
org.codehaus.groovy.runtime.BooleanClosureForMapPredicate} instead.
*/
+@Deprecated(since = "6.0.0", forRemoval = true)
+@SuppressWarnings("removal")
public class BooleanClosureForMapPredicate<K, V> implements
Predicate<Map.Entry<K, V>> {
private final BooleanReturningMethodInvoker bmi;
private final Closure wrapped;
@@ -39,21 +39,12 @@ public class BooleanClosureForMapPredicate<K, V> implements
Predicate<Map.Entry<
numberOfArguments = wrapped.getMaximumNumberOfParameters();
}
- private boolean call(Object... args) {
- return bmi.invoke(wrapped, args);
- }
-
- /**
- * If the call to the backing {@link Closure} is done on a {@link Closure}
- * taking one argument, then we give in the {@link Map.Entry}, otherwise
we will
- * give in the key and value.
- */
@Override
public boolean test(Map.Entry<K, V> entry) {
if (numberOfArguments == 2) {
- return call(entry.getKey(), entry.getValue());
+ return bmi.invoke(wrapped, entry.getKey(), entry.getValue());
} else {
- return call(entry);
+ return bmi.invoke(wrapped, entry);
}
}
}
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosurePredicate.java
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosurePredicate.java
index 2ad3b3e9db..781560089b 100644
---
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosurePredicate.java
+++
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosurePredicate.java
@@ -23,10 +23,10 @@ import groovy.lang.Closure;
import java.util.function.Predicate;
/**
- * Helper class for internal use only.
- * This creates a Predicate by calling a {@link Closure} and converting the
result to a boolean.
- * {@link BooleanReturningMethodInvoker} is used for caching.
+ * @deprecated Use {@link org.codehaus.groovy.runtime.BooleanClosurePredicate}
instead.
*/
+@Deprecated(since = "6.0.0", forRemoval = true)
+@SuppressWarnings("removal")
public class BooleanClosurePredicate<T> implements Predicate<T> {
private final BooleanReturningMethodInvoker bmi;
private final Closure wrapped;
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureWrapper.java
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureWrapper.java
index 9ad34bb1ca..79954adc60 100644
---
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureWrapper.java
+++
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanClosureWrapper.java
@@ -24,16 +24,19 @@ import java.util.Map;
import java.util.Map.Entry;
/**
- * Helper class for internal use only. This allows to call a {@link Closure}
and
+ * Helper class for internal use only. This allows to call a {@link Closure}
and
* convert the result to a boolean. It will do this by caching the possible
"doCall"
- * as well as the "asBoolean" in CallSiteArray fashion. "asBoolean" will not
be
+ * as well as the "asBoolean" in CallSiteArray fashion. "asBoolean" will not be
* called if the result is null or a Boolean. In case of null we return false
and
- * in case of a Boolean we simply unbox. This logic is designed after the one
present
+ * in case of a Boolean we simply unbox. This logic is designed after the one
present
* in {@link
org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation#castToBoolean(Object)}.
The purpose of
* this class is to avoid the slow "asBoolean" call in that method.
* {@link BooleanReturningMethodInvoker} is used for caching.
*
+ * @deprecated Use {@link org.codehaus.groovy.runtime.BooleanClosureWrapper}
instead.
*/
+@Deprecated(since = "6.0.0", forRemoval = true)
+@SuppressWarnings("removal")
public class BooleanClosureWrapper {
private final BooleanReturningMethodInvoker bmi;
private final Closure wrapped;
diff --git
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
index 171d30541f..d91693f8f9 100644
---
a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
+++
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
@@ -32,6 +32,7 @@ import org.apache.groovy.internal.util.UncheckedThrow;
* The nature of this class allows a per instance caching instead of a per
class
* caching like the normal {@link CallSiteArray} logic.
*/
+@Deprecated(since = "6.0.0", forRemoval = true)
public class BooleanReturningMethodInvoker {
private final CallSiteArray csa;
diff --git
a/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
b/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
index 25a0e66c38..fa69bea123 100644
---
a/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
+++
b/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
@@ -35,7 +35,6 @@ import
org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport;
import org.codehaus.groovy.runtime.FormatHelper;
import org.codehaus.groovy.runtime.IOGroovyMethods;
import org.codehaus.groovy.runtime.InvokerHelper;
-import org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker;
import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
import java.io.BufferedInputStream;
@@ -1326,12 +1325,11 @@ public class NioExtensions extends
DefaultGroovyMethodsSupport {
checkDir(self);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(self)) {
Iterator<Path> itr = stream.iterator();
- BooleanReturningMethodInvoker bmi = new
BooleanReturningMethodInvoker("isCase");
while (itr.hasNext()) {
Path currentPath = itr.next();
if ((fileType != FileType.FILES &&
Files.isDirectory(currentPath)) ||
(fileType != FileType.DIRECTORIES &&
Files.isRegularFile(currentPath))) {
- if (bmi.invoke(nameFilter,
currentPath.getFileName().toString()))
+ if
(DefaultTypeTransformation.castToBoolean(InvokerHelper.invokeMethod(nameFilter,
"isCase", currentPath.getFileName().toString())))
closure.call(currentPath);
}
}