]> source.dussan.org Git - sonarqube.git/commitdiff
override the method WildcardPattern.toString()
authorsimonbrandhof <simon.brandhof@gmail.com>
Fri, 7 Jan 2011 09:46:37 +0000 (10:46 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Fri, 7 Jan 2011 09:46:37 +0000 (10:46 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java

index 572d2c1d01bbc789a7beddb2f5170186284488a7..2aa913e19294e4aa03751de9ff1ff7c7bc129692 100644 (file)
@@ -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));
   }
 
@@ -80,6 +82,14 @@ public class WildcardPattern {
     return StringUtils.removeEnd(patternStr, "/");
   }
 
+  /**
+   * This method is overridden since version 2.5-RC2.
+   */
+  @Override
+  public String toString() {
+    return stringRepresentation;
+  }
+
   /**
    * @since 2.4
    */
index f57aff8f6e25d16aeeb277fb0f38a55e2fa20f4d..970544c7152637bf0c97bda5b0e3af6977babcc4 100644 (file)
@@ -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*"));
+  }
 }