Java Code Examples for com.google.common.collect.Iterables#addAll()
The following examples show how to use
com.google.common.collect.Iterables#addAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportWizard.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected void applyDiff ( final IProgressMonitor parentMonitor ) throws InterruptedException, ExecutionException { final SubMonitor monitor = SubMonitor.convert ( parentMonitor, 100 ); monitor.setTaskName ( Messages.ImportWizard_TaskName ); final Collection<DiffEntry> result = this.mergeController.merge ( wrap ( monitor.newChild ( 10 ) ) ); if ( result.isEmpty () ) { monitor.done (); return; } final Iterable<List<DiffEntry>> splitted = Iterables.partition ( result, Activator.getDefault ().getPreferenceStore ().getInt ( PreferenceConstants.P_DEFAULT_CHUNK_SIZE ) ); final SubMonitor sub = monitor.newChild ( 90 ); try { final int size = Iterables.size ( splitted ); sub.beginTask ( Messages.ImportWizard_TaskName, size ); int pos = 0; for ( final Iterable<DiffEntry> i : splitted ) { sub.subTask ( String.format ( Messages.ImportWizard_SubTaskName, pos, size ) ); final List<DiffEntry> entries = new LinkedList<DiffEntry> (); Iterables.addAll ( entries, i ); final NotifyFuture<Void> future = this.connection.getConnection ().applyDiff ( entries, null, new DisplayCallbackHandler ( getShell (), "Apply diff", "Confirmation for applying diff is required" ) ); future.get (); pos++; sub.worked ( 1 ); } } finally { sub.done (); } }
Example 2
Source File: LanguageComponentConfigBuilder.java From spoofax with Apache License 2.0 | 5 votes |
@Override public ILanguageComponentConfigBuilder addGenerates(Iterable<IGenerateConfig> generates) { if(this.generates == null) { this.generates = Lists.newArrayList(); } Iterables.addAll(this.generates, generates); return this; }
Example 3
Source File: FjFirstTypeSystem.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
protected Result<List<Field>> applyRuleFields(final RuleEnvironment G, final RuleApplicationTrace _trace_, final org.eclipse.xsemantics.example.fj.fj.Class cl) throws RuleFailedException { List<Field> fields = null; // output parameter final List<org.eclipse.xsemantics.example.fj.fj.Class> superclasses = this.superclassesInternal(_trace_, cl); Collections.reverse(superclasses); fields = CollectionLiterals.<Field>newArrayList(); for (final org.eclipse.xsemantics.example.fj.fj.Class superclass : superclasses) { List<Field> _typeSelect = EcoreUtil2.<Field>typeSelect( superclass.getMembers(), Field.class); Iterables.<Field>addAll(fields, _typeSelect); } /* fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) ) or true */ { RuleFailedException previousFailure = null; try { List<Field> _typeSelect_1 = EcoreUtil2.<Field>typeSelect( cl.getMembers(), Field.class); boolean _add = Iterables.<Field>addAll(fields, _typeSelect_1); /* fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) ) */ if (!_add) { sneakyThrowRuleFailedException("fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) )"); } } catch (Exception e) { previousFailure = extractRuleFailedException(e); /* true */ } } return new Result<List<Field>>(fields); }
Example 4
Source File: Compiler.java From compile-testing with Apache License 2.0 | 5 votes |
/** * Returns the current classpaths of the given classloader including its parents. * * @throws IllegalArgumentException if the given classloader had classpaths which we could not * determine or use for compilation. */ private static ImmutableList<File> getClasspathFromClassloader(ClassLoader currentClassloader) { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); // Concatenate search paths from all classloaders in the hierarchy 'till the system classloader. Set<String> classpaths = new LinkedHashSet<>(); while (true) { if (currentClassloader == systemClassLoader) { Iterables.addAll( classpaths, Splitter.on(StandardSystemProperty.PATH_SEPARATOR.value()) .split(StandardSystemProperty.JAVA_CLASS_PATH.value())); break; } if (currentClassloader == platformClassLoader) { break; } if (currentClassloader instanceof URLClassLoader) { // We only know how to extract classpaths from URLClassloaders. for (URL url : ((URLClassLoader) currentClassloader).getURLs()) { if (url.getProtocol().equals("file")) { classpaths.add(url.getPath()); } else { throw new IllegalArgumentException( "Given classloader consists of classpaths which are " + "unsupported for compilation."); } } } else { throw new IllegalArgumentException( String.format( "Classpath for compilation could not be extracted " + "since %s is not an instance of URLClassloader", currentClassloader)); } currentClassloader = currentClassloader.getParent(); } return classpaths.stream().map(File::new).collect(toImmutableList()); }
Example 5
Source File: SpoofaxSyntaxService.java From spoofax with Apache License 2.0 | 5 votes |
@Override public Iterable<MultiLineCommentCharacters> multiLineCommentCharacters(ILanguageImpl language) { final Iterable<SyntaxFacet> facets = language.facets(SyntaxFacet.class); final Set<MultiLineCommentCharacters> chars = Sets.newLinkedHashSet(); for(SyntaxFacet facet : facets) { Iterables.addAll(chars, facet.multiLineCommentCharacters); } return chars; }
Example 6
Source File: AbstractXtextResourceSetTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testResourcesAreInMap_02() { final XtextResourceSet rs = this.createEmptyResourceSet(); Assert.assertEquals(0, rs.getURIResourceMap().size()); final XtextResource resource = new XtextResource(); resource.setURI(URI.createFileURI(new File("foo").getAbsolutePath())); EList<Resource> _resources = rs.getResources(); ArrayList<Resource> _newArrayList = CollectionLiterals.<Resource>newArrayList(resource); Iterables.<Resource>addAll(_resources, _newArrayList); Assert.assertEquals(1, rs.getURIResourceMap().size()); rs.getResources().remove(resource); Assert.assertTrue(resource.eAdapters().isEmpty()); Assert.assertEquals(0, rs.getURIResourceMap().size()); }
Example 7
Source File: SavedModel.java From jpmml-tensorflow with GNU Affero General Public License v3.0 | 4 votes |
public Iterable<NodeDef> getInputs(String name, String... ops){ NodeDef nodeDef = getNodeDef(name); Collection<Trail> trails = new LinkedHashSet<>(); collectInputs(new ArrayDeque<>(), nodeDef, new HashSet<>(Arrays.asList(ops)), trails); Function<Trail, NodeDef> function = new Function<Trail, NodeDef>(){ @Override public NodeDef apply(Trail trail){ return trail.getNodeDef(); } }; Collection<NodeDef> inputs = new LinkedHashSet<>(); Iterables.addAll(inputs, Iterables.transform(trails, function)); return inputs; }
Example 8
Source File: CleanInputBuilder.java From spoofax with Apache License 2.0 | 4 votes |
/** * Adds given language implementations. */ public CleanInputBuilder addLanguages(Iterable<? extends ILanguageImpl> languages) { Iterables.addAll(this.languages, languages); return this; }
Example 9
Source File: AnnotationReferenceBuildContextImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void _setValue(final JvmStringAnnotationValue it, final String[] value, final String componentType, final boolean mustBeArray) { EList<String> _values = it.getValues(); Iterables.<String>addAll(_values, ((Iterable<? extends String>)Conversions.doWrapArray(value))); }
Example 10
Source File: RichStringToLineModel.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public void acceptLineBreak(final int charCount, final boolean semantic, final boolean startNewLine) { this.startContent(); if ((this.contentStartOffset > 0)) { final String lastLinesContent = this.document.substring(this.contentStartOffset, this.offset); boolean _isEmpty = this.model.getLines().isEmpty(); if (_isEmpty) { this.model.setLeadingText(lastLinesContent); this.contentStartColumn = 0; } else { final Line lastLine = IterableExtensions.<Line>last(this.model.getLines()); lastLine.setContent(lastLinesContent); int _offset = lastLine.getOffset(); int _newLineCharCount = lastLine.getNewLineCharCount(); int _plus = (_offset + _newLineCharCount); final int newContentStartColumn = (this.contentStartOffset - _plus); boolean _isLeadingSemanticNewLine = lastLine.isLeadingSemanticNewLine(); if (_isLeadingSemanticNewLine) { if ((newContentStartColumn > this.contentStartColumn)) { final int length = (newContentStartColumn - this.contentStartColumn); final String text = this.document.substring((this.contentStartOffset - length), this.contentStartOffset); SemanticWhitespace _semanticWhitespace = new SemanticWhitespace(text, newContentStartColumn); this.indentationStack.push(_semanticWhitespace); } } if ((newContentStartColumn < this.contentStartColumn)) { List<SemanticWhitespace> _list = IterableExtensions.<SemanticWhitespace>toList(Iterables.<SemanticWhitespace>filter(this.indentationStack, SemanticWhitespace.class)); for (final SemanticWhitespace ws : _list) { int _column = ws.getColumn(); boolean _greaterThan = (_column > newContentStartColumn); if (_greaterThan) { this.indentationStack.remove(ws); } } final Chunk lastWs = IterableExtensions.<Chunk>last(this.indentationStack); int _xifexpression = (int) 0; if ((lastWs == null)) { int _rootIndentLenght = this.model.getRootIndentLenght(); _xifexpression = (newContentStartColumn - _rootIndentLenght); } else { int _xifexpression_1 = (int) 0; if ((lastWs instanceof SemanticWhitespace)) { int _column_1 = ((SemanticWhitespace)lastWs).getColumn(); _xifexpression_1 = (newContentStartColumn - _column_1); } else { _xifexpression_1 = 0; } _xifexpression = _xifexpression_1; } final int length_1 = _xifexpression; if ((length_1 > 0)) { final String text_1 = this.document.substring((this.contentStartOffset - length_1), this.contentStartOffset); SemanticWhitespace _semanticWhitespace_1 = new SemanticWhitespace(text_1, newContentStartColumn); this.indentationStack.push(_semanticWhitespace_1); } } if (this._outdentThisLine) { boolean _empty = this.indentationStack.empty(); boolean _not = (!_empty); if (_not) { this.indentationStack.pop(); } this._outdentThisLine = false; } lastLine.setIndentLength(newContentStartColumn); if ((newContentStartColumn != 0)) { this.contentStartColumn = newContentStartColumn; } List<Chunk> _chunks = IterableExtensions.<Line>last(this.model.getLines()).getChunks(); Iterables.<Chunk>addAll(_chunks, this.indentationStack); } } if (this.indentNextLine) { TemplateWhitespace _templateWhitespace = new TemplateWhitespace(""); this.indentationStack.push(_templateWhitespace); this.indentNextLine = false; } this.contentStartOffset = (-1); this.content = false; if (startNewLine) { List<Line> _lines = this.model.getLines(); Line _line = new Line(this.offset, semantic, charCount); _lines.add(_line); } }
Example 11
Source File: TitanGraphStep.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Override public void addAll(Iterable<HasContainer> has) { Iterables.addAll(hasContainers, has); }
Example 12
Source File: AnnotationReferenceBuildContextImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void _setValue(final JvmCharAnnotationValue it, final char[] value, final String componentType, final boolean mustBeArray) { EList<Character> _values = it.getValues(); Iterables.<Character>addAll(_values, ((Iterable<? extends Character>)Conversions.doWrapArray(value))); }
Example 13
Source File: JavaLibraryHelper.java From bazel with Apache License 2.0 | 4 votes |
/** Adds the given source files to be compiled. */ public JavaLibraryHelper addSourceFiles(Iterable<Artifact> sourceFiles) { Iterables.addAll(this.sourceFiles, sourceFiles); return this; }
Example 14
Source File: BulkWriterResponse.java From metron with Apache License 2.0 | 4 votes |
/** * Adds all provided successes. * * @param allSuccesses Successes to add */ public void addAllSuccesses(Iterable<MessageId> allSuccesses) { if(allSuccesses != null) { Iterables.addAll(successes, allSuccesses); } }
Example 15
Source File: MultiIndexDao.java From metron with Apache License 2.0 | 4 votes |
public MultiIndexDao(Iterable<IndexDao> composedDao) { this.indices = new ArrayList<>(); Iterables.addAll(indices, composedDao); }
Example 16
Source File: AspectDefinition.java From bazel with Apache License 2.0 | 4 votes |
/** Adds the given toolchains as requirements for this aspect. */ public Builder addRequiredToolchains(Label... toolchainLabels) { Iterables.addAll(this.requiredToolchains, Lists.newArrayList(toolchainLabels)); return this; }
Example 17
Source File: AnnotationReferenceBuildContextImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void _setValue(final JvmLongAnnotationValue it, final long[] value, final String componentType, final boolean mustBeArray) { EList<Long> _values = it.getValues(); Iterables.<Long>addAll(_values, ((Iterable<? extends Long>)Conversions.doWrapArray(value))); }
Example 18
Source File: JavaSourcesSubject.java From compile-testing with Apache License 2.0 | 4 votes |
@Override public JavaSourcesSubject withCompilerOptions(Iterable<String> options) { Iterables.addAll(this.options, options); return this; }
Example 19
Source File: SimpleHbaseEnrichmentWriter.java From metron with Apache License 2.0 | 4 votes |
public KeyTransformer(Iterable<String> keys, String delim) { Iterables.addAll(this.keys, keys); keySet = new HashSet<>(this.keys); this.delim = delim == null?this.delim:delim; }
Example 20
Source File: ObjcCompilationContext.java From bazel with Apache License 2.0 | 4 votes |
public Builder addDefines(Iterable<String> defines) { Iterables.addAll(this.defines, defines); return this; }