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