+ * Create a new YangTextSchemaSource with a specific source identifier and backed
+ * by ByteSource, which provides the actual InputStreams.
+ *
+ * @param identifier SourceIdentifier of the resulting schema source
+ * @param delegate Backing ByteSource instance
+ * @return A new YangTextSchemaSource
+ */
+ public static @NonNull YangTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
+ final ByteSource delegate) {
+ return new DelegatedYangTextSchemaSource(identifier, delegate);
+ }
+
+ /**
+ * Create a new YangTextSchemaSource with {@link SourceIdentifier} derived from a supplied filename and backed
+ * by ByteSource, which provides the actual InputStreams.
+ *
+ * @param fileName File name
+ * @param delegate Backing ByteSource instance
+ * @return A new YangTextSchemaSource
+ * @throws IllegalArgumentException if the file name has invalid format
+ */
+ public static @NonNull YangTextSchemaSource delegateForByteSource(final String fileName,
+ final ByteSource delegate) {
+ return new DelegatedYangTextSchemaSource(identifierFromFilename(fileName), delegate);
+ }
+
+ /**
+ * Create a new YangTextSchemaSource backed by a {@link File} with {@link SourceIdentifier} derived from the file
+ * name.
+ *
+ * @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 {@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(identifier, file);
+ }
+
+ /**
+ * Create a new {@link YangTextSchemaSource} backed by a resource available in the ClassLoader where this
+ * class resides.
+ *
+ * @param resourceName Resource name
+ * @return A new instance.
+ * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format