Remove YangTextSchemaSourceRegistration 29/109229/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 8 Dec 2023 16:56:00 +0000 (17:56 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 8 Dec 2023 16:56:26 +0000 (17:56 +0100)
This interface brings very little to the table, just use a plain
Registration.

JIRA: YANGTOOLS-1551
Change-Id: I69f3fe915c8d35e479ae8fa75313b532ea3b120c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/AbstractYangTextSchemaSourceRegistration.java [deleted file]
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaContextResolver.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaSourceRegistration.java [deleted file]

diff --git a/parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/AbstractYangTextSchemaSourceRegistration.java b/parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/AbstractYangTextSchemaSourceRegistration.java
deleted file mode 100644 (file)
index bbab150..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.repo;
-
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-
-public abstract class AbstractYangTextSchemaSourceRegistration extends AbstractObjectRegistration<YangTextSchemaSource>
-        implements YangTextSchemaSourceRegistration {
-    protected AbstractYangTextSchemaSourceRegistration(final YangTextSchemaSource instance) {
-        super(instance);
-    }
-}
index b3929828e354b3ffff810b7b605b865d6f94618c..4fae062dc12deb4d1419a4f1928c07f998065a9c 100644 (file)
@@ -7,7 +7,6 @@
  */
 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;
@@ -100,15 +99,14 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
      * 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);
 
@@ -149,7 +147,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
             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) {
@@ -172,11 +170,10 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
      * @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)));
diff --git a/parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaSourceRegistration.java b/parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaSourceRegistration.java
deleted file mode 100644 (file)
index 361750b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.repo;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-
-public interface YangTextSchemaSourceRegistration extends ObjectRegistration<YangTextSchemaSource> {
-    @Override
-    void close();
-}