Expose URLYangTextSource
[yangtools.git] / model / yang-model-spi / src / main / java / org / opendaylight / yangtools / yang / model / spi / source / YangTextSource.java
index 9fbdb35a839e3a2c3bba791f5129764916905b32..1e52e39b8f81a8704cb211f97e272bc0dfe25c2e 100644 (file)
@@ -12,10 +12,8 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.io.CharSource;
-import com.google.common.io.Resources;
 import java.io.File;
 import java.io.InputStream;
-import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
@@ -79,76 +77,6 @@ public abstract class YangTextSource extends CharSource implements YangSourceRep
         throw new IllegalArgumentException("Supplied path " + path + " is not a regular file");
     }
 
-    /**
-     * Create a new {@link YangTextSource} 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 YangTextSource forResource(final String resourceName) {
-        return forResource(YangTextSource.class, resourceName);
-    }
-
-    /**
-     * Create a new {@link YangTextSource} 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 YangTextSource forResource(final Class<?> clazz, final String resourceName) {
-        return forResource(clazz, resourceName, StandardCharsets.UTF_8);
-    }
-
-    /**
-     * Create a new {@link YangTextSource} backed by a resource by a resource available on the ClassLoader
-     * which loaded the specified class.
-     *
-     * @param clazz Class reference
-     * @param resourceName Resource name
-     * @param charset Expected character set
-     * @return A new instance.
-     * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
-     */
-    public static @NonNull YangTextSource forResource(final Class<?> clazz, final String resourceName,
-            final Charset charset) {
-        final var fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
-        final var identifier = SourceIdentifier.ofYangFileName(fileName);
-        final var url = Resources.getResource(clazz, resourceName);
-        return new ResourceYangTextSource(identifier, url, charset);
-    }
-
-
-    /**
-     * Create a new {@link YangTextSource} 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 YangTextSource forURL(final URL url, final SourceIdentifier identifier) {
-        return forURL(url, identifier, StandardCharsets.UTF_8);
-    }
-
-    /**
-     * Create a new {@link YangTextSource} backed by a URL.
-     *
-     * @param url Backing URL
-     * @param identifier Source identifier
-     * @param charset Expected character set
-     * @return A new instance.
-     * @throws NullPointerException if any argument is {@code null}
-     */
-    public static @NonNull YangTextSource forURL(final URL url, final SourceIdentifier identifier,
-            final Charset charset) {
-        return new ResourceYangTextSource(identifier, url, charset);
-    }
-
     @Override
     public final Class<YangTextSource> getType() {
         return YangTextSource.class;