Use NodeIdentifier.create() in yang-data-util
[yangtools.git] / yang / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / UnorderedMapMixinContextNode.java
1 /*
2  * Copyright (c) 2015 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.yangtools.yang.data.util;
9
10 import java.util.Collections;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
16
17 class UnorderedMapMixinContextNode extends AbstractMixinContextNode<NodeIdentifier> {
18
19     private final ListItemContextNode innerNode;
20
21     public UnorderedMapMixinContextNode(final ListSchemaNode list) {
22         super(NodeIdentifier.create(list.getQName()), list);
23         this.innerNode = new ListItemContextNode(new NodeIdentifierWithPredicates(list.getQName(),
24                 Collections.<QName, Object> emptyMap()), list);
25     }
26
27     @Override
28     public DataSchemaContextNode<?> getChild(final PathArgument child) {
29         if (child.getNodeType().equals(getIdentifier().getNodeType())) {
30             return innerNode;
31         }
32         return null;
33     }
34
35     @Override
36     public DataSchemaContextNode<?> getChild(final QName child) {
37         if (getIdentifier().getNodeType().equals(child)) {
38             return innerNode;
39         }
40         return null;
41     }
42
43 }