X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fserialization%2FPathArgumentType.java;fp=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fserialization%2FPathArgumentType.java;h=20009d8347564c59d6f98ff537324938f6168a87;hb=f722659d5c1f6893105d1eb016a2859c08846717;hp=0000000000000000000000000000000000000000;hpb=945a63ae76181f7cda4b052fa8fcdf115da4cf2d;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/PathArgumentType.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/PathArgumentType.java new file mode 100644 index 0000000000..20009d8347 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/PathArgumentType.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * 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.serialization; + +import com.google.common.base.Preconditions; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +public enum PathArgumentType { + AUGMENTATION_IDENTIFIER, + NODE_IDENTIFIER, + NODE_IDENTIFIER_WITH_VALUE, + NODE_IDENTIFIER_WITH_PREDICATES; + + public static int getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){ + Preconditions.checkNotNull(pathArgument, "pathArgument should not be null"); + + if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){ + return AUGMENTATION_IDENTIFIER.ordinal(); + } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifier){ + return NODE_IDENTIFIER.ordinal(); + } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates){ + return NODE_IDENTIFIER_WITH_PREDICATES.ordinal(); + } else if(pathArgument instanceof YangInstanceIdentifier.NodeWithValue){ + return NODE_IDENTIFIER_WITH_VALUE.ordinal(); + } + throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument.toString()); + } + +}