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.schema.ContainerNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
16 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
17 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
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() {
38 // Create a list builder
39 CollectionNodeBuilder<MapEntryNode, SystemMapNode> cars =
40 ImmutableMapNodeBuilder.create().withNodeIdentifier(
41 new YangInstanceIdentifier.NodeIdentifier(
44 // Create an entry for the person jack
46 ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack")
47 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack"))
48 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L))
51 // Create an entry for the person jill
53 ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill")
54 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill"))
55 .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L))
61 return ImmutableContainerNodeBuilder.create()
62 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME))
63 .withChild(cars.build())
68 public static ContainerNode emptyContainer() {
69 return ImmutableContainerNodeBuilder.create()
71 new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME))
75 public static SystemMapNode newPersonMapNode() {
76 return ImmutableNodes.mapNodeBuilder(PERSON_QNAME).build();
79 public static MapEntryNode newPersonEntry(final String name) {
80 return ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, name)
81 .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name)).build();
84 public static YangInstanceIdentifier newPersonPath(final String name) {
85 return YangInstanceIdentifier.builder(PERSON_LIST_PATH)
86 .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name).build();