aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-03-12 10:11:58 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-03-12 10:12:58 +0100
commit5b9610629c73c65f7ccb23ba8151925d5cbdca35 (patch)
tree341a393dbaf954d9799f79ce9e573c0867cdc45a /sonar-plugin-api
parentd39705e47be776b16f1824d5a810359337749bc0 (diff)
downloadsonarqube-5b9610629c73c65f7ccb23ba8151925d5cbdca35.tar.gz
sonarqube-5b9610629c73c65f7ccb23ba8151925d5cbdca35.zip
SONAR-926 add DefaultInputFile#toString()
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java41
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java6
2 files changed, 29 insertions, 18 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
index ac44f17ea4d..888ae7ac313 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
@@ -196,24 +196,6 @@ public class DefaultInputFile implements InputFile, org.sonar.api.resources.Inpu
return this;
}
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- DefaultInputFile that = (DefaultInputFile) o;
- return relativePath.equals(that.relativePath);
- }
-
- @Override
- public int hashCode() {
- return relativePath.hashCode();
- }
-
/**
* @deprecated in 4.2. Replaced by {@link org.sonar.api.batch.fs.FileSystem#baseDir()}
*/
@@ -249,6 +231,29 @@ public class DefaultInputFile implements InputFile, org.sonar.api.resources.Inpu
public InputStream getInputStream() throws FileNotFoundException {
return new BufferedInputStream(new FileInputStream(file()));
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ DefaultInputFile that = (DefaultInputFile) o;
+ return relativePath.equals(that.relativePath);
+ }
+
+ @Override
+ public int hashCode() {
+ return relativePath.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "[relative=" + relativePath + ", abs=" + absolutePath + "]";
+ }
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
index 23f9203f591..3148a2dc4c8 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
@@ -74,4 +74,10 @@ public class DefaultInputFileTest {
assertThat(f1.hashCode()).isEqualTo(f1.hashCode());
assertThat(f1.hashCode()).isEqualTo(f1a.hashCode());
}
+
+ @Test
+ public void test_toString() throws Exception {
+ DefaultInputFile file = new DefaultInputFile("src/Foo.php").setAbsolutePath("/path/to/src/Foo.php");
+ assertThat(file.toString()).isEqualTo("[relative=src/Foo.php, abs=/path/to/src/Foo.php]");
+ }
}