X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FPathArgumentTypes.java;h=07ed12ab52e686cadc8ed27bc1576da8e012cf5a;hp=b01beb8c779b5b80907a0afcf51cc04f58c54d60;hb=183262480ae244c68ef056773259e9be751b31c1;hpb=139937c2e646894af6a9b2b8a8a1047c6ef82485 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..07ed12ab52 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 @@ -5,35 +5,37 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.datastore.node.utils.stream; -import com.google.common.collect.ImmutableMap; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import static com.google.common.base.Preconditions.checkArgument; +import com.google.common.collect.ImmutableMap; import java.util.Map; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; + +final class PathArgumentTypes { + static final byte AUGMENTATION_IDENTIFIER = 1; + static final byte NODE_IDENTIFIER = 2; + static final byte NODE_IDENTIFIER_WITH_VALUE = 3; + static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4; + + private PathArgumentTypes() { + throw new UnsupportedOperationException("Utility class"); + } -public 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){ - - 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(AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER) + .put(NodeIdentifier.class, NODE_IDENTIFIER) + .put(NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES) + .put(NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build(); + static byte getSerializablePathArgumentType(final PathArgument pathArgument) { + final Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass()); + checkArgument(type != null, "Unknown type of PathArgument = %s", pathArgument); return type; } - }