[New] ObjectHelper.isIn() extended to allow left and right side to be an array/collection

This commit is contained in:
Robert von Burg 2024-01-11 12:32:03 +01:00
parent 83f575de41
commit 8b20e4392d
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 29 additions and 4 deletions

View File

@ -252,10 +252,35 @@ public class ObjectHelper {
}
}
if (right instanceof Object[] arr) {
for (Object o : arr) {
if (equals(left, o, ignoreCase))
return true;
if (right instanceof Object[] arrayRight) {
if (left instanceof Collection<?> collectionLeft) {
for (Object o : arrayRight) {
for (Object l : collectionLeft) {
if (equals(l, o, ignoreCase))
return true;
}
}
return false;
} else if (left instanceof String[] leftArr) {
for (Object o : arrayRight) {
for (Object l : leftArr) {
if (equals(l, o, ignoreCase))
return true;
}
}
return false;
} else {
for (Object o : arrayRight) {
if (equals(left, o, ignoreCase))
return true;
}
}
return false;