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
9 package org.opendaylight.controller.md.cluster.datastore.model;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
17 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
19 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
21 public class CarsModel {
22 public static final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars", "2014-03-13",
25 public static final QName CARS_QNAME = QName.create(BASE_QNAME, "cars");
26 public static final QName CAR_QNAME = QName.create(CARS_QNAME, "car");
27 public static final QName CAR_NAME_QNAME = QName.create(CAR_QNAME, "name");
28 public static final QName CAR_PRICE_QNAME = QName.create(CAR_QNAME, "price");
31 public static NormalizedNode create(){
33 // Create a list builder
34 CollectionNodeBuilder<MapEntryNode, MapNode> cars =
35 ImmutableMapNodeBuilder.create().withNodeIdentifier(
36 new InstanceIdentifier.NodeIdentifier(
37 QName.create(CARS_QNAME, "car")));
39 // Create an entry for the car altima
41 ImmutableNodes.mapEntryBuilder(CARS_QNAME, CAR_NAME_QNAME, "altima")
42 .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "altima"))
43 .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, 1000))
46 // Create an entry for the car accord
48 ImmutableNodes.mapEntryBuilder(CARS_QNAME, CAR_NAME_QNAME, "accord")
49 .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "accord"))
50 .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, 2000))
53 cars.withChild(altima);
54 cars.withChild(honda);
56 return ImmutableContainerNodeBuilder.create()
57 .withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(BASE_QNAME))
58 .withChild(cars.build())
63 public static NormalizedNode emptyContainer(){
64 return ImmutableContainerNodeBuilder.create()
65 .withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(BASE_QNAME))