Bump versions 9.0.4-SNAPSHOT
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / BaListBuilder.java
index 018246e922042e61002402b96e0d37433c98b0c9..444ec2fc752040c357190b688ea71463a438e14e 100644 (file)
@@ -5,12 +5,13 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.dsbenchmark;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Map;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
@@ -19,29 +20,34 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchm
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListKey;
 
 public final class BaListBuilder {
+    private BaListBuilder() {
+
+    }
+
     public static List<OuterList> buildOuterList(final int outerElements, final int innerElements) {
         List<OuterList> outerList = new ArrayList<>(outerElements);
         for (int j = 0; j < outerElements; j++) {
             outerList.add(new OuterListBuilder()
-                                .setId( j )
-                                .setInnerList(buildInnerList(j, innerElements))
-                                .setKey(new OuterListKey( j ))
-                                .build());
+                .setId(j)
+                .setInnerList(buildInnerList(j, innerElements))
+                .withKey(new OuterListKey(j))
+                .build());
         }
         return outerList;
     }
 
-    private static List<InnerList> buildInnerList( final int index, final int elements ) {
-        List<InnerList> innerList = new ArrayList<>( elements );
+    private static Map<InnerListKey, InnerList> buildInnerList(final int index, final int elements) {
+        Builder<InnerListKey, InnerList> innerList = ImmutableMap.builderWithExpectedSize(elements);
 
-        final String itemStr = "Item-" + String.valueOf(index) + "-";
+        final String itemStr = "Item-" + index + "-";
         for (int i = 0; i < elements; i++) {
-            innerList.add(new InnerListBuilder()
-                                .setKey( new InnerListKey( i ) )
-                                .setName(i)
-                                .setValue( itemStr + String.valueOf( i ) )
-                                .build());
+            final InnerListKey key = new InnerListKey(i);
+            innerList.put(key, new InnerListBuilder()
+                .withKey(key)
+                .setName(i)
+                .setValue(itemStr + i)
+                .build());
         }
-        return innerList;
+        return innerList.build();
     }
 }