List of usage examples for com.google.common.collect Iterables concat
public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b)
From source file:com.google.devtools.build.lib.analysis.actions.ParamFileHelper.java
/** * Creates a command line using an external params file. * * <p>Call this with the result of {@link #getParamsFileMaybe} if it is not null. * * @param executableArgs leading arguments that should never be wrapped in a parameter file * @param isShellCommand true if this is a shell command * @param paramFileInfo parameter file information * @param parameterFile the output parameter file artifact * @param paramFileWriteAction the action that generates the parameter file *///w ww. j a va2s. c om public static CommandLine createWithParamsFile(List<String> executableArgs, boolean isShellCommand, ParamFileInfo paramFileInfo, Artifact parameterFile, ParameterFileWriteAction paramFileWriteAction) { String pathWithFlag = paramFileInfo.getFlag() + parameterFile.getExecPathString(); Iterable<String> commandArgv = Iterables.concat(executableArgs, ImmutableList.of(pathWithFlag)); return CommandLine.ofInternal(commandArgv, isShellCommand, paramFileWriteAction); }
From source file:org.waveprotocol.wave.examples.fedone.common.DeltaSequence.java
/** * Constructs a DeltaSequence which consists of the specified deltas * followed by this sequence's deltas./* w w w . jav a 2 s. c o m*/ */ public DeltaSequence prepend(Iterable<ProtocolWaveletDelta> prefixDeltas) { return new DeltaSequence(Iterables.concat(prefixDeltas, deltas), endVersion); }
From source file:org.thiesen.collections.set.impl.ImmutableSortedSet.java
@Override public ImmutableSortedSet<E> append(final E value) { return copyOf(Iterables.concat(this, Collections.singleton(value))); }
From source file:org.eclipse.elk.tree.intermediate.LevelHeightProcessor.java
/** * Set the height property for each node in the current level and for their children. The height * is the height of the tallest node in the level. * /*from ww w .j a va 2 s. co m*/ * @param currentLevel * the list of TNode at the same level, for which the neighbors and siblings should * be determined * @param progressMonitor * the current progress monitor */ private void setNeighbors(final Iterable<TNode> currentLevel, final IElkProgressMonitor progressMonitor) { /** only do something in filled levels */ if (!Iterables.isEmpty(currentLevel)) { /** create subtask for recursive descent */ IElkProgressMonitor sT = progressMonitor.subTask(Iterables.size(currentLevel) / numberOfNodes); sT.begin("Set neighbors in level", 1f); /** build empty iterator */ Iterable<TNode> nextLevel = new Iterable<TNode>() { public Iterator<TNode> iterator() { return Iterators.emptyIterator(); } }; double height = 0d; for (TNode cN : currentLevel) { /** append the children of the current node to the next level */ nextLevel = Iterables.concat(nextLevel, cN.getChildren()); /** check if the node is the tallest node so far */ if (height < cN.getSize().y) { height = cN.getSize().y; } } for (TNode cN : currentLevel) { /** set the level height for the node */ cN.setProperty(Properties.LEVELHEIGHT, height); } /** add amount of work units to the whole task */ sT.done(); /** determine neighbors by bfs and for the whole graph */ setNeighbors(nextLevel, progressMonitor); } }
From source file:org.sonar.java.model.expression.MethodInvocationTreeImpl.java
@Override public Iterable<Tree> children() { return Iterables.concat( typeArguments != null ? Collections.singletonList(typeArguments) : Collections.<Tree>emptyList(), Lists.newArrayList(methodSelect, arguments)); }
From source file:org.apache.isis.viewer.bdd.common.components.BddObjectStorePersistedObjects.java
@Override public Iterable<ObjectSpecification> specifications() { return Iterables.concat(BddObjectStorePersistedObjects.cachedInstancesBySpecMap.keySet(), operationalInstancesBySpecMap.keySet()); }
From source file:org.richfaces.resource.optimizer.resource.writer.impl.ResourceWriterImpl.java
public ResourceWriterImpl(File resourceContentsDir, Iterable<ResourceProcessor> resourceProcessors, Logger log, Set<ResourceKey> resourcesWithKnownOrder) { this.resourceContentsDir = resourceContentsDir; this.resourceProcessors = Iterables.concat(resourceProcessors, Collections.singleton(ThroughputResourceProcessor.INSTANCE)); this.log = log; this.resourcesWithKnownOrder = resourcesWithKnownOrder; resourceContentsDir.mkdirs();/*from www . ja v a 2 s . c om*/ currentTime = System.currentTimeMillis(); }
From source file:chess_.engine.classic.board.Board.java
public Iterable<Move> getAllLegalMoves() { return Iterables.unmodifiableIterable( Iterables.concat(this.whitePlayer.getLegalMoves(), this.blackPlayer.getLegalMoves())); }
From source file:com.google.devtools.build.lib.sandbox.AbstractContainerizingSandboxedSpawn.java
/** * No input can be a child of another input, because otherwise we might try to create a symlink * below another symlink we created earlier - which means we'd actually end up writing somewhere * in the workspace./*w w w . j ava2 s. com*/ * * <p>If all inputs were regular files, this situation could naturally not happen - but * unfortunately, we might get the occasional action that has directories in its inputs. * * <p>Creating all parent directories first ensures that we can safely create symlinks to * directories, too, because we'll get an IOException with EEXIST if inputs happen to be nested * once we start creating the symlinks for all inputs. */ private void createDirectories() throws IOException { LinkedHashSet<Path> dirsToCreate = new LinkedHashSet<>(); for (PathFragment path : Iterables.concat(inputs.keySet(), outputs)) { Preconditions.checkArgument(!path.isAbsolute()); Preconditions.checkArgument(!path.containsUplevelReferences()); for (int i = 0; i < path.segmentCount(); i++) { dirsToCreate.add(sandboxExecRoot.getRelative(path.subFragment(0, i))); } } for (Path path : dirsToCreate) { path.createDirectory(); } for (Path dir : writableDirs) { if (dir.startsWith(sandboxExecRoot)) { dir.createDirectoryAndParents(); } } }
From source file:org.eclipse.xtext.resource.impl.LiveShadowedResourceDescriptions.java
@Override public Iterable<IResourceDescription> getAllResourceDescriptions() { Iterable<IResourceDescription> notInLiveResourceSet = Iterables .filter(globalDescriptions.getAllResourceDescriptions(), new Predicate<IResourceDescription>() { @Override/*from w w w.j a v a 2 s . c o m*/ public boolean apply(IResourceDescription input) { return !isExistingOrRenamedResourceURI(input.getURI()); } }); Iterable<IResourceDescription> result = Iterables.concat(localDescriptions.getAllResourceDescriptions(), notInLiveResourceSet); return result; }