Merge "Small fix to xsql dependencies"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / serialization / PathArgumentType.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13
14 public enum PathArgumentType {
15     AUGMENTATION_IDENTIFIER,
16     NODE_IDENTIFIER,
17     NODE_IDENTIFIER_WITH_VALUE,
18     NODE_IDENTIFIER_WITH_PREDICATES;
19
20     public static int getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){
21         Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
22
23         if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){
24             return AUGMENTATION_IDENTIFIER.ordinal();
25         } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifier){
26             return NODE_IDENTIFIER.ordinal();
27         } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates){
28             return NODE_IDENTIFIER_WITH_PREDICATES.ordinal();
29         } else if(pathArgument instanceof YangInstanceIdentifier.NodeWithValue){
30             return NODE_IDENTIFIER_WITH_VALUE.ordinal();
31         }
32         throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument.toString());
33     }
34
35 }