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%2FLithiumPathArgument.java;h=660e0a7e97dd09e629f20b6836d736cefe5edc3b;hp=764d44d49fb89bbc203c8a1b31a935dbea57e6c4;hb=e17e8a357ae1d9da2534ced9f54bffdb54c0f6a7;hpb=b394690b52324ae91124735c4ec19acc3389d4ec diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java index 764d44d49f..660e0a7e97 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java @@ -7,10 +7,6 @@ */ package org.opendaylight.controller.cluster.datastore.node.utils.stream; -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; @@ -27,15 +23,17 @@ final class LithiumPathArgument { throw new UnsupportedOperationException("Utility class"); } - 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; + if (pathArgument instanceof NodeIdentifier) { + return NODE_IDENTIFIER; + } else if (pathArgument instanceof NodeIdentifierWithPredicates) { + return NODE_IDENTIFIER_WITH_PREDICATES; + } else if (pathArgument instanceof AugmentationIdentifier) { + return AUGMENTATION_IDENTIFIER; + } else if (pathArgument instanceof NodeWithValue) { + return NODE_IDENTIFIER_WITH_VALUE; + } else { + throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument); + } } }