In my project I need to compare the URI with 15+ regex patterns. Currently I have used a if ladder to execute the appropriate code if any of them gets matched.     if (uri.matches(Constants.GET_ALL_APIS_STORE_REGEX)) {            long lastUpdatedTime = InBoundETagManager.apisGet(null, null, tenantDomain, null);        String eTag = ETagGenerator.getETag(lastUpdatedTime);        if (eTag.equals(ifNoneMatch)) {            message.getExchange().put(ETag, eTag);            generate304NotModifiedResponse(message);        }        message.getExchange().put(ETag, eTag);    } else if (uri.matches(Constants.GET_API_FOR_ID_REGEX)) {   //        /apis/{apiId}        apiId = UUIDList.get(0);        String requestedTenantDomain = RestApiUtil.getRequestedTenantDomain(tenantDomain);        long lastUpdatedTime = InBoundETagManager.apisApiIdGet(apiId, requestedTenantDomain, uri);        String eTag = ETagGenerator.getETag(lastUpdatedTime);        handleInterceptorResponse(message, ifNoneMatch, eTag);    } else if (uri.matches(Constants.GET_SWAGGER_FOR_API_ID_REGEX)) {   //  /apis/{apiId}/swagger        apiId = UUIDList.get(0);        long lastUpdatedTime = InBoundETagManager.apisApiIdSwaggerGet(apiId, tenantDomain);         String eTag = ETagGenerator.getETag(lastUpdatedTime);        if (lastUpdatedTime == 0L) {            log.info(No last updated time available for the desired API swagger json file);        }        handleInterceptorResponse(message, ifNoneMatch, eTag);    }........This code is related to a apache CXF InInterceptor and regexes are as follows:public static final String GET_ALL_APIS_STORE_REGEX=^.+/api/am/store/v0.10/apis;public static final String GET_API_FOR_ID_REGEX=^.+/api/am/store/v0.10/apis/(\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12})$;public static final String GET_SWAGGER_FOR_API_ID_REGEX = ^.+/api/am/store/v0.10/apis/(\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12})/swagger$;public static final String GET_THUMBNAIL_FOR_API_ID_REGEX = ^.+/api/am/store/v0.10/apis/(\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12})/thumbnail$;public static final String GET_DOCUMENTS_FOR_API_ID_REGEX = ^.+/api/am/store/v0.10/apis/(\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12})/documents$;
Matching URIs with regexes for Apache CXF InInterceptor
java;regex;url routing