Improve ImmutableAugmentationNodeBuilder defensiveness 64/95864/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 19 Apr 2021 19:41:10 +0000 (21:41 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Apr 2021 22:32:05 +0000 (00:32 +0200)
commit5cd37a9e9f5be8f49c26fcfc72549fcda2775e16
tree7d6f2419cb6ba81e7982bddd770cbacb40f65490
parent699b18abdf9f606b508d72f4de31ae373bc82b48
Improve ImmutableAugmentationNodeBuilder defensiveness

The check for nested augmentations is rather ugly and will trigger
a secondary UnsupportedOperationException -- simply because we are
accessing getNodeType() even for AugmentationNodes.

Fix the thinko by performing an explicit check first, which also makes
things a wee bit faster.

Change-Id: I001c8d3b7c4a53ddb2c45d7c9157f7b1081dc992
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1e24596294bdc2a57a808b77a2d9862198e4f46e)
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeBuilder.java