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
8 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
10 import static com.google.common.base.Preconditions.checkArgument;
12 import com.google.common.collect.ImmutableMap;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
20 final class LithiumPathArgument {
21 static final byte AUGMENTATION_IDENTIFIER = 1;
22 static final byte NODE_IDENTIFIER = 2;
23 static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
24 static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;
26 private LithiumPathArgument() {
27 throw new UnsupportedOperationException("Utility class");
30 private static final Map<Class<?>, Byte> CLASS_TO_ENUM_MAP = ImmutableMap.<Class<?>, Byte>builder()
31 .put(AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER)
32 .put(NodeIdentifier.class, NODE_IDENTIFIER)
33 .put(NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES)
34 .put(NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build();
36 static byte getSerializablePathArgumentType(final PathArgument pathArgument) {
37 final Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());
38 checkArgument(type != null, "Unknown type of PathArgument = %s", pathArgument);