X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=third-party%2Ftriemap%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Ftriemap%2FCNode.java;fp=third-party%2Ftriemap%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Ftriemap%2FCNode.java;h=593a66d3c21e995c92e13f93b75fd360a9738836;hb=ecb69b58c3c474c8e269cb722d50845f5945c4eb;hp=2b3885443032b74da154a6d999785d1d1cc79945;hpb=38732c9e9834ba76f7cd1bae3d2d5e50e54a0bad;p=yangtools.git diff --git a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNode.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNode.java index 2b38854430..593a66d3c2 100644 --- a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNode.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNode.java @@ -19,6 +19,7 @@ import static org.opendaylight.yangtools.triemap.Constants.HASH_BITS; import static org.opendaylight.yangtools.triemap.Constants.LEVEL_BITS; import com.google.common.base.Verify; +import com.google.common.base.VerifyException; import java.util.concurrent.ThreadLocalRandom; final class CNode extends MainNode { @@ -74,6 +75,10 @@ final class CNode extends MainNode { return (sz = csize) != NO_SIZE ? sz : (csize = computeSize(ct)); } + static VerifyException invalidElement(final BasicNode elem) { + throw new VerifyException("A CNode can contain only CNodes and SNodes, not " + elem); + } + // lends itself towards being parallelizable by choosing // a random starting offset in the array // => if there are concurrent size computations, they start @@ -105,7 +110,7 @@ final class CNode extends MainNode { } else if (elem instanceof INode) { return ((INode) elem).size(ct); } else { - throw new IllegalStateException("Unhandled element " + elem); + throw invalidElement(elem); } }