Use java.nio.file.Path in YangTextFileSchemaSource
[yangtools.git] / yang / yang-repo-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / YangTextFileSchemaSource.java
index de5f0d0a477ef0751e34f766df4254ebdfe58af7..fb795c29b14a2d5cfeffdd4cb00512f54d115b7a 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.MoreObjects.ToStringHelper;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
@@ -23,31 +23,33 @@ import org.opendaylight.yangtools.concepts.Delegator;
  *
  * @author Robert Varga
  */
-final class YangTextFileSchemaSource extends YangTextSchemaSource implements Delegator<File> {
-    private final @NonNull File file;
+final class YangTextFileSchemaSource extends YangTextSchemaSource implements Delegator<Path> {
+    private final @NonNull Path path;
 
-    YangTextFileSchemaSource(final SourceIdentifier identifier, final File file) {
+    YangTextFileSchemaSource(final SourceIdentifier identifier, final Path path) {
         super(identifier);
-        this.file = requireNonNull(file);
+        this.path = requireNonNull(path);
     }
 
     @Override
-    public File getDelegate() {
-        return file;
+    public Path getDelegate() {
+        return path;
     }
 
     @Override
     public InputStream openStream() throws IOException {
-        return Files.newInputStream(file.toPath());
+        return Files.newInputStream(path);
     }
 
     @Override
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return toStringHelper.add("file", file);
+        return toStringHelper.add("path", path);
     }
 
     @Override
     public Optional<String> getSymbolicName() {
-        return Optional.of(file.toString());
+        // FIXME: NEXT: this is forcing internal normalization. I think this boils down to providing Path back, which
+        //        is essentially getDelegate() anyway. Perhaps expose it as PathAware?
+        return Optional.of(path.toString());
     }
 }