2019-04-18 16:08:22 +02:00
|
|
|
package it.cavallium.strangedb.java.objects.lists.operations;
|
|
|
|
|
|
|
|
import it.cavallium.strangedb.java.objects.lists.KMP;
|
|
|
|
import it.cavallium.strangedb.java.objects.lists.ValueOperation;
|
|
|
|
|
|
|
|
public class ContainsIgnoreCase implements ValueOperation<String> {
|
|
|
|
|
2019-04-22 00:10:21 +02:00
|
|
|
private final CharSequence containsValue;
|
2019-04-18 16:08:22 +02:00
|
|
|
|
2019-04-22 00:10:21 +02:00
|
|
|
private ContainsIgnoreCase(CharSequence containsValue) {
|
|
|
|
this.containsValue = containsValue;
|
2019-04-18 16:08:22 +02:00
|
|
|
}
|
|
|
|
|
2019-04-22 00:10:21 +02:00
|
|
|
public static ContainsIgnoreCase containsValue(CharSequence value) {
|
2019-04-18 16:08:22 +02:00
|
|
|
return new ContainsIgnoreCase(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean evaluate(Object value) {
|
2019-04-22 00:10:21 +02:00
|
|
|
if (value instanceof CharSequence) {
|
|
|
|
return KMP.KMP( (CharSequence) value, containsValue, true) != -1;
|
2019-04-18 16:08:22 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|