/** @param regex the regex to set. {@literal null} will be treated as default value. */ public void setRegex(@Nullable String regex) { if (regex == null) regex = DEFAULT_EXPRESSION; this.regex = regex; this.pat = compile(this.regex, getNormalize().getCase()); }
/** * Apply normalisation to given string. Guaranteed to be idempotent. * * @param input * @return The normalised string. */ public String apply(String input) { return getCase().apply(input, getLocale()); }
@Override public void setNormalize(CaseNormalizer normalize) { super.setNormalize(normalize); this.pat = compile(this.regex, getNormalize().getCase()); }
@Test public void testCloneable() throws Exception { filter.setNormalize(new CaseNormalizer(Case.UPPER, Locale.ENGLISH)); StringParameterFilter clone = filter.clone(); assertThat(clone.getDefaultValue(), equalTo(filter.getDefaultValue())); assertThat(clone.getValues(), equalTo(filter.getValues())); assertThat( clone.getNormalize().getConfiguredLocale(), equalTo(filter.getNormalize().getConfiguredLocale())); assertThat(clone.getNormalize().getCase(), equalTo(filter.getNormalize().getCase())); } }
@Test public void testCloneable() throws Exception { filter.setNormalize(new CaseNormalizer(Case.UPPER, Locale.ENGLISH)); RegexParameterFilter clone = filter.clone(); assertThat(clone.getDefaultValue(), equalTo(filter.getDefaultValue())); assertThat(clone.getRegex(), equalTo(filter.getRegex())); assertThat( clone.getNormalize().getConfiguredLocale(), equalTo(filter.getNormalize().getConfiguredLocale())); assertThat(clone.getNormalize().getCase(), equalTo(filter.getNormalize().getCase())); } }