Do not subclass YangTextSchemaSource in yang-parser-impl
[yangtools.git] / yang / yang-repo-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / YangTextSchemaSource.java
index 0e521561aa6927ae7c8225e215a7903da39b961a..2d87b9c905c9a7aa7acf6e88933a3898f994dfbf 100644 (file)
@@ -78,11 +78,24 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @param file Backing File
      * @return A new YangTextSchemaSource
      * @throws IllegalArgumentException if the file name has invalid format or if the supplied File is not a file
-     * @throws NullPointerException if file is null
+     * @throws NullPointerException if file is {@code null}
      */
     public static @NonNull YangTextSchemaSource forFile(final File file) {
+        return forFile(file, identifierFromFilename(file.getName()));
+    }
+
+    /**
+     * Create a new YangTextSchemaSource backed by a {@link File} and specified {@link SourceIdentifier}.
+     *
+     * @param file Backing File
+     * @param identifier source identifier
+     * @return A new YangTextSchemaSource
+     * @throws IllegalArgumentException if the file name has invalid format or if the supplied File is not a file
+     * @throws NullPointerException if any argument is {@code null}
+     */
+    public static @NonNull YangTextSchemaSource forFile(final File file, final SourceIdentifier identifier) {
         checkArgument(file.isFile(), "Supplied file %s is not a file", file);
-        return new YangTextFileSchemaSource(identifierFromFilename(file.getName()), file);
+        return new YangTextFileSchemaSource(identifier, file);
     }
 
     /**
@@ -113,6 +126,18 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
         return new ResourceYangTextSchemaSource(identifier, url);
     }
 
+    /**
+     * Create a new {@link YangTextSchemaSource} backed by a URL.
+     *
+     * @param url Backing URL
+     * @param identifier Source identifier
+     * @return A new instance.
+     * @throws NullPointerException if any argument is {@code null}
+     */
+    public static @NonNull YangTextSchemaSource forURL(final URL url, final SourceIdentifier identifier) {
+        return new ResourceYangTextSchemaSource(identifier, url);
+    }
+
     @Override
     public final SourceIdentifier getIdentifier() {
         return identifier;