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