[New] Added array as AND searching in contains*()
This commit is contained in:
parent
1729460784
commit
164fc0ac80
|
@ -365,7 +365,9 @@ public class StrolchSearchTest {
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, isNotEqualTo("dfgdfg")))
|
.and(param(BAG_ID, PARAM_STRING_ID, isNotEqualTo("dfgdfg")))
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, isNotEqualToIgnoreCase("dfgdfg")))
|
.and(param(BAG_ID, PARAM_STRING_ID, isNotEqualToIgnoreCase("dfgdfg")))
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, contains("rol")))
|
.and(param(BAG_ID, PARAM_STRING_ID, contains("rol")))
|
||||||
|
.and(param(BAG_ID, PARAM_STRING_ID, contains(new String[] { "Str", "rol" })))
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, containsIgnoreCase("ROL")))
|
.and(param(BAG_ID, PARAM_STRING_ID, containsIgnoreCase("ROL")))
|
||||||
|
.and(param(BAG_ID, PARAM_STRING_ID, containsIgnoreCase(new String[] { "STR", "ROL" })))
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, startsWith("Str")))
|
.and(param(BAG_ID, PARAM_STRING_ID, startsWith("Str")))
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, startsWithIgnoreCase("str")))
|
.and(param(BAG_ID, PARAM_STRING_ID, startsWithIgnoreCase("str")))
|
||||||
.and(param(BAG_ID, PARAM_STRING_ID, endsWith("lch")))
|
.and(param(BAG_ID, PARAM_STRING_ID, endsWith("lch")))
|
||||||
|
|
|
@ -60,14 +60,38 @@ public class ObjectHelper {
|
||||||
return collection.contains(right);
|
return collection.contains(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left instanceof String && right instanceof String) {
|
if (left instanceof String) {
|
||||||
String str = (String) left;
|
String str = (String) left;
|
||||||
String subStr = (String) right;
|
|
||||||
|
|
||||||
if (ignoreCase)
|
if (right instanceof String[]) {
|
||||||
return str.toLowerCase().contains(subStr.toLowerCase());
|
String[] arr = (String[]) right;
|
||||||
else
|
|
||||||
return str.contains(subStr);
|
if (ignoreCase) {
|
||||||
|
str = str.toLowerCase();
|
||||||
|
for (String s : arr) {
|
||||||
|
if (!str.contains(s.toLowerCase()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (String s : arr) {
|
||||||
|
if (!str.contains(s))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (right instanceof String) {
|
||||||
|
String subStr = (String) right;
|
||||||
|
|
||||||
|
if (ignoreCase)
|
||||||
|
return str.toLowerCase().contains(subStr.toLowerCase());
|
||||||
|
else
|
||||||
|
return str.contains(subStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException("Unhandled type combination " + left.getClass() + " / " + right.getClass());
|
throw new IllegalArgumentException("Unhandled type combination " + left.getClass() + " / " + right.getClass());
|
||||||
|
|
Loading…
Reference in New Issue