Improve DistinctNodeContainer.getChildByArg() 08/105608/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Apr 2023 06:51:50 +0000 (08:51 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Apr 2023 06:51:50 +0000 (08:51 +0200)
Improve the reported exception to include the key that was being looked
up.

Change-Id: Ica2885543d5d2c68fd84db54c57948f468f8fa2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/DistinctNodeContainer.java

index dd2ad108113133e45433cb69ed302cc99538bad6..ae82f698a37e4aa31855ccce3a60075308e15c01 100644 (file)
@@ -49,7 +49,7 @@ public non-sealed interface DistinctNodeContainer<K extends PathArgument, V exte
      *
      * @param key Path argument identifying child node
      * @return Matching child node, or null if no matching child exists
-     * @throws NullPointerException if {@code key} is null
+     * @throws NullPointerException if {@code key} is {@code null}
      */
     @Nullable V childByArg(K key);
 
@@ -58,7 +58,7 @@ public non-sealed interface DistinctNodeContainer<K extends PathArgument, V exte
      *
      * @param key Path argument identifying child node
      * @return Optional with child node if child exists. {@link Optional#empty()} if child does not exist
-     * @throws NullPointerException if {@code key} is null
+     * @throws NullPointerException if {@code key} is {@code null}
      */
     default Optional<V> findChildByArg(final K key) {
         return Optional.ofNullable(childByArg(key));
@@ -69,10 +69,10 @@ public non-sealed interface DistinctNodeContainer<K extends PathArgument, V exte
      *
      * @param key Path argument identifying child node
      * @return Matching child node
-     * @throws NullPointerException if {@code key} is null
+     * @throws NullPointerException if {@code key} is {@code null}
      * @throws VerifyException if the child does not exist
      */
     default @NonNull V getChildByArg(final K key) {
-        return verifyNotNull(childByArg(key));
+        return verifyNotNull(childByArg(key), "No child matching %s", key);
     }
 }