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.md.cluster.datastore.model;
10 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
18 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
20 public final class PeopleModel {
21 public static final QName BASE_QNAME = QName.create(
22 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people", "2014-03-13", "people");
24 public static final QName PEOPLE_QNAME = QName.create(BASE_QNAME, "people");
25 public static final QName PERSON_QNAME = QName.create(PEOPLE_QNAME, "person");
26 public static final QName PERSON_NAME_QNAME = QName.create(PERSON_QNAME, "name");
27 public static final QName PERSON_AGE_QNAME = QName.create(PERSON_QNAME, "age");
29 public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME);
30 public static final YangInstanceIdentifier PERSON_LIST_PATH = BASE_PATH.node(PERSON_QNAME);
32 private PeopleModel() {
36 public static ContainerNode create() {
37 return ImmutableNodes.newContainerBuilder()
38 .withNodeIdentifier(new NodeIdentifier(BASE_QNAME))
39 .withChild(ImmutableNodes.newSystemMapBuilder()
40 .withNodeIdentifier(new NodeIdentifier(PERSON_QNAME))
41 // Create an entry for the person jack
42 .withChild(mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack")
43 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack"))
44 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L))
46 // Create an entry for the person jill
47 .withChild(mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill")
48 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill"))
49 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L))
55 public static ContainerNode emptyContainer() {
56 return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(BASE_QNAME)).build();
59 public static SystemMapNode newPersonMapNode() {
60 return ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(PERSON_QNAME)).build();
63 public static MapEntryNode newPersonEntry(final String name) {
64 return mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, name)
65 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name))
69 public static YangInstanceIdentifier newPersonPath(final String name) {
70 return YangInstanceIdentifier.builder(PERSON_LIST_PATH)
71 .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name)