Check rc:yang-data template name duplications
[yangtools.git] / codec / yang-data-codec-binfmt / src / main / java / org / opendaylight / yangtools / yang / data / codec / binfmt / LithiumPathArgument.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 package org.opendaylight.yangtools.yang.data.codec.binfmt;
9
10 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14
15 final class LithiumPathArgument {
16     static final byte AUGMENTATION_IDENTIFIER = 1;
17     static final byte NODE_IDENTIFIER = 2;
18     static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
19     static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;
20
21     private LithiumPathArgument() {
22         // Utility class
23     }
24
25     static byte getSerializablePathArgumentType(final PathArgument pathArgument) {
26         if (pathArgument instanceof NodeIdentifier) {
27             return NODE_IDENTIFIER;
28         } else if (pathArgument instanceof NodeIdentifierWithPredicates) {
29             return NODE_IDENTIFIER_WITH_PREDICATES;
30         } else if (pathArgument instanceof NodeWithValue) {
31             return NODE_IDENTIFIER_WITH_VALUE;
32         } else {
33             throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument);
34         }
35     }
36 }