Add SourceIdentifier(String,Revision) 48/102648/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 8 Nov 2022 20:44:02 +0000 (21:44 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 9 Nov 2022 17:33:15 +0000 (17:33 +0000)
This is a convenience constructor which is useful when mapping
raw literals to a concrete namespace revision. Also improve
documentation a bit.

Change-Id: I955c2bdbf4d573da4ef87aec8b0f9faaecc6cb5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d3c54ad273b98f4f1811d4492fa69ffb957c109b)

yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SourceIdentifier.java

index 8b5411cd34b3367ea8e14fd5c41140dce7ee6059..4638b9ed9707a79ff2f1a748a405e8e079ecd662 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 
 import static java.util.Objects.requireNonNull;
 
+import java.time.format.DateTimeParseException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Identifier;
@@ -63,11 +64,25 @@ public record SourceIdentifier(@NonNull Unqualified name, @Nullable Revision rev
      * Creates new YANG Schema source identifier for sources with or without a revision.
      *
      * @param name Name of schema
+     * @param revision Optional schema revision
      * @throws NullPointerException if {@code name} is null
      * @throws IllegalArgumentException if {@code name} is not a valid YANG identifier
      */
+    public SourceIdentifier(final @NonNull String name, final @Nullable Revision revision) {
+        this(Unqualified.of(name), revision);
+    }
+
+    /**
+     * Creates new YANG Schema source identifier for sources with or without a revision.
+     *
+     * @param name Name of schema
+     * @param revision Optional schema revision
+     * @throws NullPointerException if {@code name} is null
+     * @throws IllegalArgumentException if {@code name} is not a valid YANG identifier
+     * @throws DateTimeParseException if {@code revision} format does not conform specification.
+     */
     public SourceIdentifier(final @NonNull String name, final @Nullable String revision) {
-        this(Unqualified.of(name), revision != null ? Revision.of(revision) : null);
+        this(name, revision != null ? Revision.of(revision) : null);
     }
 
     /**