From 8b5348d9b3b382a1d2ca160abb490ec43e4ef3fc Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Thu, 6 Apr 2023 13:51:02 +0200 Subject: [PATCH] Let setter only accept `TreeString` instances. --- src/main/java/edu/hm/hafner/coverage/FileNode.java | 4 ++-- src/test/java/edu/hm/hafner/coverage/FileNodeTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/hm/hafner/coverage/FileNode.java b/src/main/java/edu/hm/hafner/coverage/FileNode.java index da98de11..568ce553 100644 --- a/src/main/java/edu/hm/hafner/coverage/FileNode.java +++ b/src/main/java/edu/hm/hafner/coverage/FileNode.java @@ -540,8 +540,8 @@ public String getRelativePath() { * @param relativePath * the relative path */ - public void setRelativePath(final String relativePath) { - this.relativePath = TreeString.valueOf(relativePath); + public void setRelativePath(final TreeString relativePath) { + this.relativePath = relativePath; } @Override diff --git a/src/test/java/edu/hm/hafner/coverage/FileNodeTest.java b/src/test/java/edu/hm/hafner/coverage/FileNodeTest.java index d9fecab5..1be28b0e 100644 --- a/src/test/java/edu/hm/hafner/coverage/FileNodeTest.java +++ b/src/test/java/edu/hm/hafner/coverage/FileNodeTest.java @@ -55,7 +55,7 @@ void shouldGetFilePath() { assertThat(folder.getAll(Metric.FILE)).containsExactly(file); assertThat(file.getAll(Metric.FILE)).containsExactly(file); - file.setRelativePath(otherPath); + file.setRelativePath(TreeString.valueOf(otherPath)); assertThat(file.getRelativePath()).isEqualTo(otherPath); assertThat(file.matches(Metric.FILE, fileName)).isTrue();