/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.datastore.node.utils.stream;

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;

final class LithiumPathArgument {
    static final byte AUGMENTATION_IDENTIFIER = 1;
    static final byte NODE_IDENTIFIER = 2;
    static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
    static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;

    private LithiumPathArgument() {
        throw new UnsupportedOperationException("Utility class");
    }

    private static final Map<Class<?>, Byte> CLASS_TO_ENUM_MAP = ImmutableMap.<Class<?>, Byte>builder()
            .put(AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER)
            .put(NodeIdentifier.class, NODE_IDENTIFIER)
            .put(NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES)
            .put(NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build();

    static byte getSerializablePathArgumentType(final PathArgument pathArgument) {
        final Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());
        checkArgument(type != null, "Unknown type of PathArgument = %s", pathArgument);
        return type;
    }
}

@@ -379,144 +379,8 @@
 m;%0A%0A
-import static com.google.common.base.Preconditions.checkArgument;%0A%0Aimport com.google.common.collect.ImmutableMap;%0Aimport java.util.Map;%0A
 impo
@@ -1189,218 +1189,159 @@
     
-private static final Map%3CClass%3C?%3E, Byte%3E CLASS_TO_ENUM_MAP = ImmutableMap.%3CClass%3C?%3E, Byte%3Ebuilder()%0A            .put(AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER)%0A            .put(NodeIdentifier.class,
+static byte getSerializablePathArgumentType(final PathArgument pathArgument) %7B%0A        if (pathArgument instanceof NodeIdentifier) %7B%0A            return
  NOD
@@ -1352,17 +1352,17 @@
 ENTIFIER
-)
+;
 %0A       
@@ -1358,33 +1358,59 @@
 ER;%0A        
-    .put(
+%7D else if (pathArgument instanceof 
 NodeIdentifi
@@ -1425,23 +1425,38 @@
 edicates
-.class,
+) %7B%0A            return
  NODE_ID
@@ -1479,17 +1479,17 @@
 EDICATES
-)
+;
 %0A       
@@ -1493,269 +1493,284 @@
     
-    .put(NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build();%0A%0A    static byte getSerializablePathArgumentType(final PathArgument pathArgument) %7B%0A        final Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());%0A        checkArgument(type != null, 
+%7D else if (pathArgument instanceof AugmentationIdentifier) %7B%0A            return AUGMENTATION_IDENTIFIER;%0A        %7D else if (pathArgument instanceof NodeWithValue) %7B%0A            return NODE_IDENTIFIER_WITH_VALUE;%0A        %7D else %7B%0A            throw new IllegalArgumentException(
 %22Unk
@@ -1801,12 +1801,11 @@
 t = 
-%25s%22,
+%22 +
  pat
@@ -1828,20 +1828,9 @@
     
-return type;
+%7D
 %0A   

Rework PathArgumentTypes lookup