Bug 1225: Added DataBroker and DataChangeListener test suite.
[controller.git] / opendaylight / md-sal / sal-test-model / src / main / java / org / opendaylight / controller / md / sal / test / model / util / ListsBindingUtils.java
1 /*
2  * Copyright (c) 2014 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.controller.md.sal.test.model.util;
9
10 import java.util.Arrays;
11
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedListKey;
24 import org.opendaylight.yangtools.yang.binding.Augmentation;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27
28 import com.google.common.collect.ImmutableList;
29
30 public class ListsBindingUtils {
31
32     private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
33
34     private ListsBindingUtils() {
35         throw new UnsupportedOperationException();
36     }
37
38     public static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
39     public static final TopLevelListKey TOP_BAR_KEY = new TopLevelListKey("bar");
40     public static final ListViaUsesKey USES_ONE_KEY = new ListViaUsesKey("one");
41     public static final ListViaUsesKey USES_TWO_KEY = new ListViaUsesKey("two");
42
43
44     public static InstanceIdentifier<TopLevelList> path(final TopLevelListKey key) {
45         return TOP_PATH.child(TopLevelList.class, key);
46     }
47
48     public static InstanceIdentifier<NestedList> path(final TopLevelListKey top,final NestedListKey nested) {
49         return path(top).child(NestedList.class, nested);
50     }
51
52     public static InstanceIdentifier<ListViaUses> path(final TopLevelListKey top,final ListViaUsesKey uses) {
53         return path(top).augmentation(TreeComplexUsesAugment.class).child(ListViaUses.class, uses);
54     }
55
56     public static <T extends DataObject & Augmentation<TopLevelList>> InstanceIdentifier<T> path(final TopLevelListKey key, final Class<T> augmentation) {
57         return path(key).augmentation(augmentation);
58     }
59
60     public static Top top(final TopLevelList... listItems) {
61         return new TopBuilder().setTopLevelList(Arrays.asList(listItems)).build();
62     }
63
64     public static TopLevelList topLevelList(final TopLevelListKey key) {
65         return new TopLevelListBuilder().setKey(key).build();
66     }
67
68     public static TopLevelList topLevelList(final TopLevelListKey key, final TreeComplexUsesAugment augment) {
69         TopLevelListBuilder builder = new TopLevelListBuilder().setKey(key);
70         builder.addAugmentation(TreeComplexUsesAugment.class, augment);
71         return builder.build();
72     }
73
74     public static TreeComplexUsesAugment complexUsesAugment(final ListViaUsesKey... keys) {
75         ImmutableList.Builder<ListViaUses> listViaUses = ImmutableList.<ListViaUses> builder();
76         for (ListViaUsesKey key : keys) {
77             listViaUses.add(new ListViaUsesBuilder().setKey(key).build());
78         }
79         return new TreeComplexUsesAugmentBuilder().setListViaUses(listViaUses.build()).build();
80     }
81
82 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.