private static void applyStringMatcher(Map.Entry<String, Object> entry, StringMatcher stringMatcher, boolean ignoreCase) { Document document = new Document(); if (StringMatcher.DEFAULT == stringMatcher) { if (ignoreCase) { document.put("$regex", Pattern.quote((String) entry.getValue())); entry.setValue(document); } } else { String expression = MongoRegexCreator.INSTANCE.toRegularExpression((String) entry.getValue(), toMatchMode(stringMatcher)); document.put("$regex", expression); entry.setValue(document); } if (ignoreCase) { document.put("$options", "i"); } }
private static void applyStringMatcher(Map.Entry<String, Object> entry, StringMatcher stringMatcher, boolean ignoreCase) { Document document = new Document(); if (StringMatcher.DEFAULT == stringMatcher) { if (ignoreCase) { document.put("$regex", Pattern.quote((String) entry.getValue())); entry.setValue(document); } } else { String expression = MongoRegexCreator.INSTANCE.toRegularExpression((String) entry.getValue(), toMatchMode(stringMatcher)); document.put("$regex", expression); entry.setValue(document); } if (ignoreCase) { document.put("$options", "i"); } }