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 org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
17 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
19 public final class PeopleModel {
20 public static final QName BASE_QNAME = QName.create(
21 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people", "2014-03-13", "people");
23 public static final QName PEOPLE_QNAME = QName.create(BASE_QNAME, "people");
24 public static final QName PERSON_QNAME = QName.create(PEOPLE_QNAME, "person");
25 public static final QName PERSON_NAME_QNAME = QName.create(PERSON_QNAME, "name");
26 public static final QName PERSON_AGE_QNAME = QName.create(PERSON_QNAME, "age");
28 public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME);
29 public static final YangInstanceIdentifier PERSON_LIST_PATH = BASE_PATH.node(PERSON_QNAME);
31 private PeopleModel() {
35 public static ContainerNode create() {
36 return Builders.containerBuilder()
37 .withNodeIdentifier(new NodeIdentifier(BASE_QNAME))
38 .withChild(Builders.mapBuilder()
39 .withNodeIdentifier(new NodeIdentifier(PERSON_QNAME))
40 // Create an entry for the person jack
41 .withChild(ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack")
42 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack"))
43 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L))
45 // Create an entry for the person jill
46 .withChild(ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill")
47 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill"))
48 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L))
54 public static ContainerNode emptyContainer() {
55 return Builders.containerBuilder()
56 .withNodeIdentifier(new NodeIdentifier(BASE_QNAME))
60 public static SystemMapNode newPersonMapNode() {
61 return ImmutableNodes.mapNodeBuilder(PERSON_QNAME).build();
64 public static MapEntryNode newPersonEntry(final String name) {
65 return ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, name)
66 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name))
70 public static YangInstanceIdentifier newPersonPath(final String name) {
71 return YangInstanceIdentifier.builder(PERSON_LIST_PATH)
72 .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name)