private List<?> mergeListsImpl(List<?> val1, Iterable<?> val2, int depthRemaining, Visited visited) { return MutableList.builder() .addAll(val1) .addAll(val2) .build(); }
protected BasicDownloadTargets(Builder builder) { primaries = ImmutableList.copyOf(builder.primaries); fallbacks = MutableList.<String>builder().addAll(builder.fallbacks).removeAll(builder.primaries).build().asUnmodifiable(); canContinueResolving = builder.canContinueResolving; }
protected List<String> getJars() { return MutableList.<String>builder().addAll(jarsToScan).addAll(jarsToScanOld).build(); }
public void testBuilderAddArray() throws Exception { List<Object> vals = MutableList.builder().addAll(new Object[] {1,2,3}).build(); Assert.assertEquals(vals, ImmutableList.of(1,2,3)); }
public void testBuilderAddIterator() throws Exception { List<Object> vals = MutableList.builder().addAll(ImmutableList.of(1,2).iterator()).build(); Assert.assertEquals(vals, ImmutableList.of(1,2)); }
public void testBuilderRetainAll() throws Exception { List<Object> vals = MutableList.builder() .add(1,2,3) .retainAll(ImmutableList.of(1,2)) .build(); Assert.assertEquals(vals, ImmutableList.of(1,2)); }
public void testBuilderAddVarargs() throws Exception { List<Object> vals = MutableList.builder().add(1,2,3).build(); Assert.assertEquals(vals, ImmutableList.of(1,2,3)); }
public void testBuilderAddIterable() throws Exception { List<Object> vals = MutableList.builder().addAll(ImmutableList.of(1,2)).addAll(ImmutableList.of(2,3)).build(); Assert.assertEquals(vals, ImmutableList.of(1,2,2,3)); }
public void testBuilderRemoveAll() throws Exception { List<Object> vals = MutableList.builder() .add(1,2,3) .removeAll(ImmutableList.of(2,3)) .add(4) .build(); Assert.assertEquals(vals, ImmutableList.of(1,4)); }
public void testBuilderAddIfNotNull() throws Exception { List<Object> vals = MutableList.builder().addIfNotNull(1).addIfNotNull(null).build(); Assert.assertEquals(vals, ImmutableList.of(1)); }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder() .addAll(super.getCustomJavaConfigOptions()) .add("-Xms200m") .add("-Xmx800m") .add("-XX:MaxPermSize=400m") .build(); }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder() .addAll(super.getCustomJavaConfigOptions()) .add("-Xms200m") .add("-Xmx800m") .add("-XX:MaxPermSize=400m") .build(); }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder() .addAll(super.getCustomJavaConfigOptions()) .add("-Xms200m") .add("-Xmx800m") .add("-XX:MaxPermSize=400m") .build(); }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder() .addAll(super.getCustomJavaConfigOptions()) .addAll(getEntity().getJvmXArgs()) .build(); }
public void testBuilderRemoval() throws Exception { List<Object> vals = MutableList.builder() .add(1,2,3) .remove(2) .add(4) .build(); Assert.assertEquals(vals, ImmutableList.of(1,3,4)); }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder() .addAll(super.getCustomJavaConfigOptions()) .add("-Xms200m") .add("-Xmx800m") .add("-XX:MaxPermSize=400m") .build(); }
/** * Builds the command to retrieve the stdout and stderr of the async command. * An offset can be given, to only retrieve data starting at a particular character (indexed from 0). */ protected List<String> buildRetrieveStdoutAndStderrCommand(int stdoutPosition, int stderrPosition) { // Note that `tail -c +1` means start at the *first* character (i.e. start counting from 1, not 0) String catStdoutCmd = "tail -c +"+(stdoutPosition+1)+" "+stdoutPath+" 2> /dev/null"; String catStderrCmd = "tail -c +"+(stderrPosition+1)+" "+stderrPath+" 2>&1 > /dev/null"; MutableList.Builder<String> cmds = MutableList.<String>builder() .add((runAsRoot ? BashCommands.sudo(catStdoutCmd) : catStdoutCmd)) .add((runAsRoot ? BashCommands.sudo(catStderrCmd) : catStderrCmd)) .add("RESULT=$?"); cmds.add("exit $RESULT"); return cmds.build(); }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder().addAll(super.getCustomJavaConfigOptions()).add("-Dabc=def").build(); } }
@Override protected List<String> getCustomJavaConfigOptions() { return MutableList.<String>builder() .addAll(super.getCustomJavaConfigOptions()) .add("-server") .build(); }; };
@Test public void testExistingChildrenToppedUpWhenNewMembersIfMoreLocations() throws Exception { List<Location> locs = ImmutableList.of(loc1, loc2, loc3); DynamicFabric fabric = app.createAndManageChild(EntitySpec.create(DynamicFabric.class) .configure(DynamicFabric.MEMBER_SPEC, EntitySpec.create(TestEntity.class))); TestEntity existingChild = fabric.addChild(EntitySpec.create(TestEntity.class)); app.start(locs); // Expect three children: the existing one, and one per other location assertEquals(fabric.getChildren().size(), 3, "children="+fabric.getChildren()); assertTrue(fabric.getChildren().contains(existingChild), "children="+fabric.getChildren()+"; existingChild="+existingChild); Asserts.assertEqualsIgnoringOrder(fabric.getMembers(), fabric.getChildren()); List<Location> remainingLocs = MutableList.<Location>builder().addAll(locs).build(); for (Entity child : fabric.getChildren()) { Collection<Location> childLocs = child.getLocations(); assertEquals(childLocs.size(), 1, "childLocs="+childLocs); assertTrue(remainingLocs.remove(Iterables.get(childLocs, 0)), "childLocs="+childLocs+"; remainingLocs="+remainingLocs+"; allLocs="+locs); } }