*/
package org.opendaylight.yangtools.yang.parser.repo;
-import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
* Register a {@link YangTextSchemaSource}.
*
* @param source YANG text source
- * @return a YangTextSchemaSourceRegistration
+ * @return a {@link Registration}
* @throws YangSyntaxErrorException When the YANG file is syntactically invalid
* @throws IOException when the URL is not readable
* @throws SchemaSourceException When parsing encounters general error
+ * @throws NullPointerException if {@code source} is {@code null}
*/
- public @NonNull YangTextSchemaSourceRegistration registerSource(final @NonNull YangTextSchemaSource source)
+ public @NonNull Registration registerSource(final @NonNull YangTextSchemaSource source)
throws SchemaSourceException, IOException, YangSyntaxErrorException {
- checkArgument(source != null);
-
final var ast = TextToIRTransformer.transformText(source);
LOG.trace("Resolved source {} to source {}", source, ast);
LOG.debug("Added source {} to schema context requirements", parsedId);
version = new Object();
- return new AbstractYangTextSchemaSourceRegistration(text) {
+ return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (YangTextSchemaContextResolver.this) {
* @throws YangSyntaxErrorException When the YANG file is syntactically invalid
* @throws IOException when the URL is not readable
* @throws SchemaSourceException When parsing encounters general error
+ * @throws NullPointerException if {@code url} is {@code null}
*/
- public @NonNull YangTextSchemaSourceRegistration registerSource(final @NonNull URL url)
+ public @NonNull Registration registerSource(final @NonNull URL url)
throws SchemaSourceException, IOException, YangSyntaxErrorException {
- checkArgument(url != null, "Supplied URL must not be null");
-
final String path = url.getPath();
final String fileName = path.substring(path.lastIndexOf('/') + 1);
return registerSource(YangTextSchemaSource.forURL(url, guessSourceIdentifier(fileName)));