Rework PathArgumentTypes lookup
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / 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.controller.cluster.datastore.node.utils.stream;
9
10 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15
16 final class LithiumPathArgument {
17     static final byte AUGMENTATION_IDENTIFIER = 1;
18     static final byte NODE_IDENTIFIER = 2;
19     static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
20     static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;
21
22     private LithiumPathArgument() {
23         throw new UnsupportedOperationException("Utility class");
24     }
25
26     static byte getSerializablePathArgumentType(final PathArgument pathArgument) {
27         if (pathArgument instanceof NodeIdentifier) {
28             return NODE_IDENTIFIER;
29         } else if (pathArgument instanceof NodeIdentifierWithPredicates) {
30             return NODE_IDENTIFIER_WITH_PREDICATES;
31         } else if (pathArgument instanceof AugmentationIdentifier) {
32             return AUGMENTATION_IDENTIFIER;
33         } else if (pathArgument instanceof NodeWithValue) {
34             return NODE_IDENTIFIER_WITH_VALUE;
35         } else {
36             throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument);
37         }
38     }
39 }