private static final Map<String, WildcardPattern> patterns = new HashMap<String, WildcardPattern>();
private Pattern pattern;
+ private String stringRepresentation;
protected WildcardPattern(String pattern, String directorySeparator) {
+ this.stringRepresentation = pattern;
this.pattern = Pattern.compile(toRegexp(pattern, directorySeparator));
}
return StringUtils.removeEnd(patternStr, "/");
}
+ /**
+ * This method is overridden since version 2.5-RC2.
+ */
+ @Override
+ public String toString() {
+ return stringRepresentation;
+ }
+
/**
* @since 2.4
*/
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class WildcardPatternTest {
assertTrue(WildcardPattern.match(patterns, "Bar"));
assertFalse(WildcardPattern.match(patterns, "Other"));
}
+
+ @Test
+ public void testToString() {
+ assertThat(WildcardPattern.create("foo*").toString(), is("foo*"));
+ }
}