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:org.axdt.avm.scoping.AvmPropertyScope.java
@Override protected Iterable<IEObjectDescription> getCandidates() { AvmTypeAccess access = getQualifierType(); if (access == null) return Collections.emptySet(); Iterable<IEObjectDescription> dynDesc = null; if (access instanceof AvmTypeAccess.Builder) { AvmPackage pack = ((AvmTypeAccess.Builder) access).getPackage(); if (pack instanceof AvmContainerPackage) { return ((AvmContainerPackage) pack).getChildren(); }/* w w w . j av a 2 s. c om*/ return Iterables.transform(Iterables.filter(pack.eContents(), AvmReferable.class), GetDesciption); } else if (access != AvmTypeAccess.NULL) { AvmType type = access.getType(); type = resolveType(type, null); if (type.isDynamic()) { AvmReferable dynIdent = getDynamicIdentifiable(getReference()); if (dynIdent != null) dynDesc = Collections.singleton(GetDesciption.apply(dynIdent)); } if (type instanceof AvmDeclaredType) { AvmDeclaredType typeDec = (AvmDeclaredType) type; Iterable<IEObjectDescription> members = Iterables.transform(getAllMembers(typeDec, access), GetDesciption); if (dynDesc != null) members = Iterables.concat(members, dynDesc); return members; } } if (dynDesc != null) return dynDesc; return Collections.emptySet(); }
From source file:org.sonar.java.JavaSquid.java
public JavaSquid(JavaVersion javaVersion, @Nullable SonarComponents sonarComponents, @Nullable Measurer measurer, JavaResourceLocator javaResourceLocator, @Nullable CodeVisitorIssueFilter postAnalysisIssueFilter, CodeVisitor... visitors) { List<CodeVisitor> commonVisitors = Lists.newArrayList(javaResourceLocator); if (postAnalysisIssueFilter != null) { commonVisitors.add(postAnalysisIssueFilter); }/*from ww w. ja v a 2 s . c o m*/ Iterable<CodeVisitor> codeVisitors = Iterables.concat(commonVisitors, Arrays.asList(visitors)); Collection<CodeVisitor> testCodeVisitors = Lists.newArrayList(commonVisitors); if (measurer != null) { Iterable<CodeVisitor> measurers = Collections.singletonList(measurer); codeVisitors = Iterables.concat(measurers, codeVisitors); testCodeVisitors.add(measurer.new TestFileMeasurer()); } List<File> classpath = Lists.newArrayList(); List<File> testClasspath = Lists.newArrayList(); if (sonarComponents != null) { if (!sonarComponents.isSonarLintContext()) { codeVisitors = Iterables.concat(codeVisitors, Arrays.asList(new FileLinesVisitor(sonarComponents), new SyntaxHighlighterVisitor(sonarComponents))); testCodeVisitors.add(new SyntaxHighlighterVisitor(sonarComponents)); } classpath = sonarComponents.getJavaClasspath(); testClasspath = sonarComponents.getJavaTestClasspath(); testCodeVisitors.addAll(sonarComponents.testCheckClasses()); } //AstScanner for main files ActionParser<Tree> parser = JavaParser.createParser(); astScanner = new JavaAstScanner(parser, sonarComponents); boolean enableSymbolicExecution = hasASymbolicExecutionCheck(visitors); astScanner.setVisitorBridge(createVisitorBridge(codeVisitors, classpath, javaVersion, sonarComponents, enableSymbolicExecution)); //AstScanner for test files astScannerForTests = new JavaAstScanner(parser, sonarComponents); astScannerForTests.setVisitorBridge( createVisitorBridge(testCodeVisitors, testClasspath, javaVersion, sonarComponents, false)); }
From source file:org.apache.fluo.core.observer.v1.ObserversV1.java
public ObserversV1(Environment env, Map<Column, org.apache.fluo.api.config.ObserverSpecification> strongObservers, Map<Column, org.apache.fluo.api.config.ObserverSpecification> weakObservers) { this.env = env; this.strongObservers = strongObservers; this.weakObservers = weakObservers; this.aliases = new HashMap<>(); for (Entry<Column, org.apache.fluo.api.config.ObserverSpecification> e : Iterables .concat(strongObservers.entrySet(), weakObservers.entrySet())) { org.apache.fluo.api.config.ObserverSpecification observerConfig = e.getValue(); try {/* w w w .j a v a2 s . c o m*/ String alias = Class.forName(observerConfig.getClassName()).asSubclass(Observer.class) .getSimpleName(); aliases.put(e.getKey(), alias); } catch (ClassNotFoundException e1) { throw new RuntimeException(e1); } } }
From source file:com.cloudera.science.ml.core.vectors.Centers.java
/** * Construct a new {@code Centers} object made up of the given {@code Vector} * and the points contained in this instance. * //from w w w . j a va2 s .co m * @param point The new point * @return A new {@code Centers} instance */ public Centers extendWith(Vector point) { return new Centers(Iterables.concat(centers, ImmutableList.of(point))); }
From source file:org.caleydo.view.tourguide.internal.compute.ComputeStratificationJob.java
@Override public IStatus run(IProgressMonitor monitor) { if (data.isEmpty() || (stratScores.isEmpty() && stratMetrics.isEmpty())) return Status.OK_STATUS; final int total = data.size() + 1; monitor.beginTask("Compute LineUp Scores", total); log.info("computing similarity of %d against %d stratification scores, %d stratification metrics", data.size(), stratScores.size(), stratMetrics.size()); Stopwatch w = new Stopwatch().start(); // first initialize all algorithms progress(0, "Initializing..."); for (IComputedStratificationScore score : Iterables.concat(stratMetrics, stratScores)) { score.getAlgorithm().init(monitor); if (Thread.interrupted() || monitor.isCanceled()) return Status.CANCEL_STATUS; }//from w w w.ja v a2s . c om int c = 0; monitor.worked(1); progress(c++ / (float) total, "Computing..."); Iterator<IComputeElement> it = this.data.iterator(); // first time the one run to compute the progress frequency interval { IComputeElement as = it.next(); if (!run(monitor, as)) return Status.CANCEL_STATUS; monitor.worked(1); c++; } final int fireEvery = fireEvery(w.elapsedMillis()); int f = fireEvery - 1; while (it.hasNext()) { IComputeElement as = it.next(); if (f == 0) { progress(c / (float) total, "Computing " + as.getLabel()); f = fireEvery; } f--; if (!run(monitor, as)) return Status.CANCEL_STATUS; monitor.worked(1); c++; } System.out.println("done in " + w); monitor.done(); return Status.OK_STATUS; }
From source file:org.sonar.server.computation.task.projectanalysis.webhook.WebhookPostTask.java
@Override public void finished(ProjectAnalysis analysis) { Settings settings = settingsRepository.getSettings(rootHolder.getRoot()); Iterable<String> webhookProps = Iterables.concat( getWebhookProperties(settings, WebhookProperties.GLOBAL_KEY), getWebhookProperties(settings, WebhookProperties.PROJECT_KEY)); if (!Iterables.isEmpty(webhookProps)) { process(settings, analysis, webhookProps); deliveryStorage.purge(analysis.getProject().getUuid()); }//from ww w. j av a 2 s. c o m }
From source file:com.google.jenkins.plugins.metadata.scm.SourceMetadataExtractor.java
/** * Extracts zero or more {@code SourceMetadata} from the given build and * returns them./*w ww . j a v a 2s . c o m*/ * * <p>Currently there are extension points to extract metadata from build * actions and the project's SCM. */ @Nullable public static Iterable<SourceMetadata> extract(Run<?, ?> build, SCM scm, ChangeLogSet<?> changelog) { HashMap<String, SourceMetadata> merged = Maps.newHashMap(); List<SourceMetadata> notDeduped = Lists.newArrayList(); for (Map.Entry<String, SourceMetadata> entry : Iterables .concat(FromBuildActions.extract(build, changelog).entries(), FromSCM.extract(scm).entries())) { if (entry.getKey().isEmpty()) { // The empty string is a special key that means "don't dedupe". notDeduped.add(entry.getValue()); } else { // For nonempty keys, look for a previously processed SourceMetadata and // merge with it if it exists. SourceMetadata metadata = merged.get(entry.getKey()); if (metadata != null) { metadata = metadata.mergeFrom(entry.getValue()); } else { metadata = entry.getValue(); } merged.put(entry.getKey(), metadata); } } return Iterables.concat(merged.values(), notDeduped); }
From source file:eu.lp0.cursus.scoring.scores.impl.GenericRacePenaltiesData.java
@Override protected int calculateRacePenalties(Pilot pilot, Race race) { RaceAttendee attendee = race.getAttendees().get(pilot); if (attendee == null) { return 0; }//from w w w. ja v a 2 s. co m if (noRacePenaltiesForSimulated) { if (scores.hasSimulatedRacePoints(pilot, race)) { return 0; } } int autoPenalties = countPreviousAutomaticPenalties(pilot, race); int penalties = 0; for (Penalty penalty : Iterables.concat(Ordering.natural().immutableSortedCopy(attendee.getPenalties()), getSimulatedRacePenalties(pilot, race))) { switch (penalty.getType()) { case AUTOMATIC: if (penalty.getValue() >= 0) { // Add multiple automatic penalties for (int i = 0; i < penalty.getValue(); i++) { penalties += ++autoPenalties; } } else { // Remove multiple automatic penalties for (int i = penalty.getValue(); i > 0; i--) { if (autoPenalties > 0) { penalties -= autoPenalties--; } } } break; case FIXED: // Fixed penalty added/removed penalties += penalty.getValue(); break; case CANCEL_LAPS: case ADJUST_LAPS: // These is applied in RaceLapsData break; case EVENT_NON_ATTENDANCE: // This should only be applied in OverallPenaltiesData Preconditions.checkArgument(false, "Invalid race penalty type: " + penalty.getType()); //$NON-NLS-1$ break; } } // Can't have negative race penalties because we need // to be able to remove them from the race points later // and negative race points doesn't make sense if (penalties < 0) { penalties = 0; } return penalties; }
From source file:com.facebook.buck.shell.ShBinaryRule.java
@Override public Iterable<String> getInputsToCompareToOutput() { return Iterables.concat(ImmutableList.of(main.toString()), SourcePaths.filterInputsToCompareToOutput(resources)); }
From source file:org.apache.james.GuiceJamesServer.java
public GuiceJamesServer combineWith(Module... modules) { return new GuiceJamesServer( Modules.combine(Iterables.concat(Arrays.asList(module), Arrays.asList(modules)))); }