jtulach commented on code in PR #9820:
URL: https://github.com/apache/netbeans/pull/9820#discussion_r4680268885


##########
platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java:
##########
@@ -833,16 +833,30 @@ public static File toFile(FileObject fo) {
         return retVal;
     }
     
-    /** Finds appropriate java.nio.file.Path to FileObject if possible.
-     * If not possible then null is returned.
-     * This is the inverse operation of {@link #toFileObject}.
-     * @param fo FileObject whose corresponding Path will be looked for
-     * @return java.nio.file.Path or null if no corresponding File exists.
+    /** Finds appropriate {@link Path} for given {@code FileObject}.
+     * Since version <em>9.50</em> it is guaranteed that the return value
+     * <em>will never be {@code null}</em> for an object with valid {@link 
FileObject#getFileSystem()}.
+     * A fully functional {@link Path}
+     * instance is created even for fully virtual {@code FileObject}s.
+     *
+     * This is the inverse operation of {@link 
#toFileObject(java.nio.file.Path) }.
+     * @param fo object to find corresponding Path for
+     * @return {@link Path} for the {@code FileObject} never {@code null}
+     * 
      * @since 9.32
      */
     public static Path toPath(FileObject fo) {
+        Parameters.notNull("fo", fo);
         File f = toFile(fo);

Review Comment:
   - `toFile(fo)` check was put here by @lkishalmi and I am trying to not 
modify it. 
   - it works fine for `LocalFileSystem` and masterfs to provide the 
underlaying `Path` implementations
   - it works less well for `MultiFileSystem` which can also have underlaying 
impl
      - there I will have to disable the delegation
      - but that can be done locally inside the module now ...
      - ... without any visible API
   
   > Is conversion via attribute documented?
   
   - probably it is not 
   - it should be listed in [this 
table](https://bits.netbeans.org/dev/javadoc/org-openide-filesystems/index.html#group-property)
   
   >  check for (Path) fo.getAttribute("java.nio.Path")
   
   - not in this PR (unless necessary), but for the future I'd like to do 
something bigger:
   - let us **add** `FileObject implements Path`!
   - then any `FileObject` will immediately be usable with any JDK path 
oriented API



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to