2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
11 import com.google.common.collect.ImmutableMap;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 public class PathArgumentTypes {
17 public static final byte AUGMENTATION_IDENTIFIER = 1;
18 public static final byte NODE_IDENTIFIER = 2;
19 public static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
20 public static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;
22 private static Map<Class<?>, Byte> CLASS_TO_ENUM_MAP =
23 ImmutableMap.<Class<?>, Byte>builder().
24 put(YangInstanceIdentifier.AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER).
25 put(YangInstanceIdentifier.NodeIdentifier.class, NODE_IDENTIFIER).
26 put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES).
27 put(YangInstanceIdentifier.NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build();
29 public static byte getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){
31 Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());
33 throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument);