8378e8b3c8b8c8e7bbc1c20938149c440c0626c0
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / BaListBuilder.java
1 /*
2  * Copyright (c) 2015 Cisco Systems 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.dsbenchmark;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListKey;
18
19 public final class BaListBuilder {
20     private BaListBuilder() {
21
22     }
23
24     public static List<OuterList> buildOuterList(final int outerElements, final int innerElements) {
25         List<OuterList> outerList = new ArrayList<>(outerElements);
26         for (int j = 0; j < outerElements; j++) {
27             outerList.add(new OuterListBuilder()
28                                 .setId(j)
29                                 .setInnerList(buildInnerList(j, innerElements))
30                                 .withKey(new OuterListKey(j))
31                                 .build());
32         }
33         return outerList;
34     }
35
36     private static List<InnerList> buildInnerList(final int index, final int elements) {
37         List<InnerList> innerList = new ArrayList<>(elements);
38
39         final String itemStr = "Item-" + String.valueOf(index) + "-";
40         for (int i = 0; i < elements; i++) {
41             innerList.add(new InnerListBuilder()
42                                 .withKey(new InnerListKey(i))
43                                 .setName(i)
44                                 .setValue(itemStr + String.valueOf(i))
45                                 .build());
46         }
47         return innerList;
48     }
49 }