* avoid overloading issues

This commit is contained in:
Reinhard Pointner 2014-04-15 14:29:13 +00:00
parent 45a00a7d4b
commit 8cee5b9a2a
1 changed files with 36 additions and 6 deletions

View File

@ -21,10 +21,10 @@ public class ExpressionFormatFunctions {
}
}
public static Object any(Closure<?>... closures) {
for (Closure<?> it : closures) {
public static Object any(Object a0, Object a1, Object... args) {
for (Object it : new Object[] { a0, a1 }) {
try {
Object result = it.call();
Object result = callIfCallable(it);
if (result != null) {
return result;
}
@ -32,15 +32,38 @@ public class ExpressionFormatFunctions {
// ignore
}
}
for (Object it : args) {
try {
Object result = callIfCallable(it);
if (result != null) {
return result;
}
} catch (Exception e) {
// ignore
}
}
return null;
}
public static List<Object> allOf(Closure<?>... closures) {
public static List<Object> allOf(Object a0, Object a1, Object... args) {
List<Object> values = new ArrayList<Object>();
for (Closure<?> it : closures) {
for (Object it : new Object[] { a0, a1 }) {
try {
Object result = it.call();
Object result = callIfCallable(it);
if (result != null) {
values.add(result);
}
} catch (Exception e) {
// ignore
}
}
for (Object it : args) {
try {
Object result = callIfCallable(it);
if (result != null) {
values.add(result);
}
@ -52,4 +75,11 @@ public class ExpressionFormatFunctions {
return values;
}
private static Object callIfCallable(Object obj) throws Exception {
if (obj instanceof Closure<?>) {
return ((Closure<?>) obj).call();
}
return obj;
}
}