
org.xlcloud.rest.client.cache.URLResourceComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-client Show documentation
Show all versions of rest-client Show documentation
This module provides base classes for creation of REST client (SDK).
Default client has preconfigured filters, Oauth2 token injection or even object mapper.
The newest version!
/*
* Copyright 2012 AMG.lab, a Bull Group Company
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xlcloud.rest.client.cache;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
/**
* Resource comparator based on URL address. It is based on OpenAM URL
* conventions include * and -*-
*
* @author Michał Kamiński, AMG.net
*/
public class URLResourceComparator implements ResourceComparator {
private Pattern pattern;
public URLResourceComparator( String urlPattern ) {
urlPattern = StringUtils.replace(urlPattern, "*", ".*");
urlPattern = "^(/)?" + StringUtils.replace(urlPattern, "-.*-", "(?:(?!/).)*?") + "(/)?(\\?.*)?$";
pattern = Pattern.compile(urlPattern);
}
/** {@inheritDoc} */
@Override
public boolean match(String urlAddress) {
return pattern.matcher(urlAddress).matches();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy