![JAR search and dependency download from the Maven repository](/logo.png)
org.swisspush.redisques.util.HandlerUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisques Show documentation
Show all versions of redisques Show documentation
A highly scalable redis-persistent queuing system for vertx
package org.swisspush.redisques.util;
import io.vertx.redis.client.Response;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;
public class HandlerUtil {
/**
* Apply the given filter pattern to the given JsonArray containing the list of queues/locks.
* @param response list of JSON objects containing the queueName/lockName to be filtered
* @param filterPattern The filter regex pattern to be matched against the given queues/locks list
* @return The resulting filtered list of queues/locks. If there is no filter given, the full list
* of queues/locks is returned.
*/
public static List filterByPattern(Response response, Optional filterPattern) {
List queues = new ArrayList<>();
if (filterPattern != null && filterPattern.isPresent()) {
Pattern pattern = filterPattern.get();
for (int i = 0; i < response.size(); i++) {
String queue = response.get(i).toString();
if (pattern.matcher(queue).find()) {
queues.add(queue);
}
}
} else {
for (int i = 0; i < response.size(); i++) {
queues.add(response.get(i).toString());
}
}
return queues;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy