X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FPathArgumentTypes.java;h=b372d8f9157ae645b56ff2c99d3c509f77074e5a;hb=da9ee8c80328bd6e21064e44f95f29ffc1e99d41;hp=b01beb8c779b5b80907a0afcf51cc04f58c54d60;hpb=a1878a52f1d6df37acae733430911fbce5be1d50;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/PathArgumentTypes.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/PathArgumentTypes.java index b01beb8c77..b372d8f915 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/PathArgumentTypes.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/PathArgumentTypes.java @@ -8,31 +8,30 @@ package org.opendaylight.controller.cluster.datastore.node.utils.stream; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - import java.util.Map; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -public class PathArgumentTypes { +final class PathArgumentTypes { public static final byte AUGMENTATION_IDENTIFIER = 1; public static final byte NODE_IDENTIFIER = 2; public static final byte NODE_IDENTIFIER_WITH_VALUE = 3; public static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4; - private static Map, Byte> CLASS_TO_ENUM_MAP = - ImmutableMap., Byte>builder(). - put(YangInstanceIdentifier.AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER). - put(YangInstanceIdentifier.NodeIdentifier.class, NODE_IDENTIFIER). - put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES). - put(YangInstanceIdentifier.NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build(); - - public static byte getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){ + private PathArgumentTypes() { + throw new UnsupportedOperationException("Utility class"); + } - Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass()); - if(type == null) { - throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument); - } + private static final Map, Byte> CLASS_TO_ENUM_MAP = ImmutableMap., Byte>builder() + .put(YangInstanceIdentifier.AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER) + .put(YangInstanceIdentifier.NodeIdentifier.class, NODE_IDENTIFIER) + .put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES) + .put(YangInstanceIdentifier.NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build(); + public static byte getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument) { + final Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass()); + Preconditions.checkArgument(type != null, "Unknown type of PathArgument = %s", pathArgument); return type; }