+ public static @NonNull YangTextSchemaSource forFile(final File file) {
+ checkArgument(file.isFile(), "Supplied file %s is not a file", file);
+ return new YangTextFileSchemaSource(identifierFromFilename(file.getName()), 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
+ */
+ public static @NonNull YangTextSchemaSource forResource(final String resourceName) {
+ return forResource(YangTextSchemaSource.class, resourceName);
+ }
+
+ /**
+ * Create a new {@link YangTextSchemaSource} backed by a resource by a resource available on the ClassLoader
+ * which loaded the specified class.
+ *
+ * @param clazz Class reference
+ * @param resourceName Resource name
+ * @return A new instance.
+ * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
+ */
+ public static @NonNull YangTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
+ final String fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
+ final SourceIdentifier identifier = identifierFromFilename(fileName);
+ final URL url = Resources.getResource(clazz, resourceName);
+ return new ResourceYangTextSchemaSource(identifier, url);
+ }
+