1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

Added List.joining(delim, prefix, suffix) convenience method

This commit is contained in:
Reinhard Pointner 2016-10-08 23:13:07 +08:00
parent 845dc26c83
commit db85b77dad

View File

@ -374,6 +374,14 @@ public class ExpressionFormatMethods {
return self;
}
public static String joining(List<?> self, String delimiter, String prefix, String suffix) {
String[] list = self.stream().filter(Objects::nonNull).map(Objects::toString).filter(s -> !s.isEmpty()).toArray(String[]::new);
if (list.length == 0) {
return null;
}
return prefix + String.join(delimiter, list) + suffix;
}
/**
* Unwind if an object does not satisfy the given predicate
*