Fix non-generic references to NormalizedNode
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / serialization / NormalizedNodeType.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
9 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
20 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
23 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
24 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
25 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
26
27 public enum NormalizedNodeType {
28     CONTAINER_NODE_TYPE,
29     LEAF_NODE_TYPE,
30     MAP_NODE_TYPE,
31     MAP_ENTRY_NODE_TYPE,
32     AUGMENTATION_NODE_TYPE,
33     LEAF_SET_NODE_TYPE,
34     LEAF_SET_ENTRY_NODE_TYPE,
35     CHOICE_NODE_TYPE,
36     ORDERED_LEAF_SET_NODE_TYPE,
37     ORDERED_MAP_NODE_TYPE,
38     UNKEYED_LIST_NODE_TYPE,
39     UNKEYED_LIST_ENTRY_NODE_TYPE,
40     ANY_XML_NODE_TYPE;
41
42     public static NormalizedNodeType getSerializableNodeType(NormalizedNode<?, ?> node){
43         Preconditions.checkNotNull(node, "node should not be null");
44
45         if(node instanceof LeafNode){
46             return LEAF_NODE_TYPE;
47         } else if(node instanceof LeafSetEntryNode){
48             return LEAF_SET_ENTRY_NODE_TYPE;
49         } else if(node instanceof MapEntryNode){
50             return MAP_ENTRY_NODE_TYPE;
51         } else if(node instanceof ContainerNode){
52             return CONTAINER_NODE_TYPE;
53         } else if(node instanceof MapNode){
54             return MAP_NODE_TYPE;
55         } else if(node instanceof AugmentationNode){
56             return AUGMENTATION_NODE_TYPE;
57         } else if(node instanceof LeafSetNode){
58             return LEAF_SET_NODE_TYPE;
59         } else if(node instanceof ChoiceNode){
60             return CHOICE_NODE_TYPE;
61         } else if(node instanceof OrderedLeafSetNode){
62             return ORDERED_LEAF_SET_NODE_TYPE;
63         } else if(node instanceof OrderedMapNode){
64             return ORDERED_MAP_NODE_TYPE;
65         } else if(node instanceof UnkeyedListNode){
66             return UNKEYED_LIST_NODE_TYPE;
67         } else if(node instanceof UnkeyedListEntryNode){
68             return UNKEYED_LIST_ENTRY_NODE_TYPE;
69         } else if(node instanceof AnyXmlNode){
70             return ANY_XML_NODE_TYPE;
71         }
72
73         throw new IllegalArgumentException("Node type unknown : " + node.getClass().getSimpleName());
74     }
75
76 }