run.halo.app.extension.index.query.StringContains Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
API of halo project, connecting by other projects.
The newest version!
package run.halo.app.extension.index.query;
import com.google.common.collect.Sets;
import java.util.Map;
import java.util.NavigableSet;
import org.apache.commons.lang3.StringUtils;
public class StringContains extends SimpleQuery {
public StringContains(String fieldName, String value) {
super(fieldName, value);
}
@Override
public NavigableSet matches(QueryIndexView indexView) {
var resultSet = Sets.newTreeSet();
var indexEntry = indexView.getIndexEntry(fieldName);
indexEntry.acquireReadLock();
try {
for (Map.Entry entry : indexEntry.entries()) {
var fieldValue = entry.getKey();
if (StringUtils.containsIgnoreCase(fieldValue, value)) {
resultSet.add(entry.getValue());
}
}
return resultSet;
} finally {
indexEntry.releaseReadLock();
}
}
@Override
public String toString() {
return "contains(" + fieldName + ", '" + value + "')";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy