mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-15 13:55:03 -05:00
* avoid overloading issues
This commit is contained in:
parent
45a00a7d4b
commit
8cee5b9a2a
@ -21,10 +21,10 @@ public class ExpressionFormatFunctions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object any(Closure<?>... closures) {
|
public static Object any(Object a0, Object a1, Object... args) {
|
||||||
for (Closure<?> it : closures) {
|
for (Object it : new Object[] { a0, a1 }) {
|
||||||
try {
|
try {
|
||||||
Object result = it.call();
|
Object result = callIfCallable(it);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -32,15 +32,38 @@ public class ExpressionFormatFunctions {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Object it : args) {
|
||||||
|
try {
|
||||||
|
Object result = callIfCallable(it);
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
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>();
|
List<Object> values = new ArrayList<Object>();
|
||||||
|
|
||||||
for (Closure<?> it : closures) {
|
for (Object it : new Object[] { a0, a1 }) {
|
||||||
try {
|
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) {
|
if (result != null) {
|
||||||
values.add(result);
|
values.add(result);
|
||||||
}
|
}
|
||||||
@ -52,4 +75,11 @@ public class ExpressionFormatFunctions {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Object callIfCallable(Object obj) throws Exception {
|
||||||
|
if (obj instanceof Closure<?>) {
|
||||||
|
return ((Closure<?>) obj).call();
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user