public class RegexRequestURLBuilder
extends java.lang.Object
implements com.google.common.base.Function<java.lang.String,java.lang.String>
The function uses standard Java regular expression components from the java.util.regex package.
It is therefore helpful to have an understanding of the use of these Java classes.
The runtime logic is effectively:
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(entityID);
if (matcher.matches()) {
return matcher.replaceAll(replacement);
else {
return null;
}
For supported regular expression syntax see Pattern. For details on the replacement operation,
see Matcher.replaceAll(String).
It is expected that the typical use case is that the supplied replacement string will be a combination of literal text combined with back references to the regular expression match groups, e.g. $1, $2, etc.
If the regular expression does not match the entity ID, or if there is an error in evaluating the regular expression, then null is returned.
| Modifier and Type | Field and Description |
|---|---|
private org.slf4j.Logger |
log
Logger.
|
private java.util.regex.Pattern |
pattern
The compiled pattern.
|
private java.lang.String |
template
The replacement template.
|
| Constructor and Description |
|---|
RegexRequestURLBuilder(java.lang.String regex,
java.lang.String replacement)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
apply(java.lang.String entityID) |
private final org.slf4j.Logger log
private java.util.regex.Pattern pattern
private java.lang.String template
public RegexRequestURLBuilder(@Nonnull @NotEmpty
java.lang.String regex,
@Nonnull @NotEmpty
java.lang.String replacement)
regex - the regular expression against which to evaluate the entity IDreplacement - the the replacement template string.