You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Goooler (via GitHub)" <gi...@apache.org> on 2023/02/19 08:00:22 UTC

[GitHub] [groovy] Goooler commented on a diff in pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Goooler commented on code in PR #1859:
URL: https://github.com/apache/groovy/pull/1859#discussion_r1111187417


##########
subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java:
##########
@@ -101,6 +101,36 @@ public static long size(Path self) throws IOException {
         return Files.size(self);
     }
 
+    /**
+     * Provide the extension of this path.
+     *
+     * @param self a path object
+     * @return the extension of this path (not including the dot), or an empty string if it doesn't have one.
+     * @since 5.0.0
+     */
+    public static String getExtension(Path self) {
+        final Path fileName = self.getFileName();
+        final String name = fileName == null ? "" : fileName.toString();

Review Comment:
   If we can resue this part, add a `Path.name()` like [`Path.name` in Kotlin](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/name.html)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org