[New] ObjectHelper.isIn() extended to allow left and right side to be an array/collection
This commit is contained in:
parent
83f575de41
commit
8b20e4392d
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue