diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-07 10:46:37 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-07 10:46:37 +0100 |
commit | 287126153cceb8deec795faeff3525cdabab3ced (patch) | |
tree | 385dbfdcd65081ee8945fdb400bde5c605a01323 | |
parent | a8a68caceaeb12c3c3cb2c22adbc41e73f3a5a04 (diff) | |
download | sonarqube-287126153cceb8deec795faeff3525cdabab3ced.tar.gz sonarqube-287126153cceb8deec795faeff3525cdabab3ced.zip |
override the method WildcardPattern.toString()
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java | 10 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java index 572d2c1d01b..2aa913e1929 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java @@ -33,8 +33,10 @@ public class WildcardPattern { 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)); } @@ -81,6 +83,14 @@ public class WildcardPattern { } /** + * This method is overridden since version 2.5-RC2. + */ + @Override + public String toString() { + return stringRepresentation; + } + + /** * @since 2.4 */ public static boolean match(WildcardPattern[] patterns, String value) { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java index f57aff8f6e2..970544c7152 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java @@ -21,7 +21,9 @@ package org.sonar.api.utils; 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 { @@ -107,4 +109,9 @@ public class WildcardPatternTest { assertTrue(WildcardPattern.match(patterns, "Bar")); assertFalse(WildcardPattern.match(patterns, "Other")); } + + @Test + public void testToString() { + assertThat(WildcardPattern.create("foo*").toString(), is("foo*")); + } } |