List of usage examples for com.google.common.collect Iterables isEmpty
public static boolean isEmpty(Iterable<?> iterable)
From source file:edu.umn.msi.tropix.persistence.service.security.impl.SecurityProviderImpl.java
public boolean canReadAll(final Iterable<String> tropixObjectIds, final String userGridId) { boolean canReadAll = true; if (!Iterables.isEmpty(tropixObjectIds)) { canReadAll = canReadAllNonEmpty(tropixObjectIds, userGridId); }//w ww . ja va2 s. c o m return canReadAll; }
From source file:org.polarsys.reqcycle.utils.collect.collectors.WidthCollector.java
/** * Width wise collection./*from ww w .j ava2 s . c o m*/ * * @param handler * the handler that processes each element. * @param element * : the current layer from which the collection is performed. * @throws CollectionAbortedException */ protected void collectWidthWise(ResultHandler<T> handler, Iterable<T> currentLayer) throws CollectionAbortedException { Iterable<T> nextLayer = Collections.emptyList(); while (currentLayer != null && !Iterables.isEmpty(currentLayer)) { for (T currentElement : currentLayer) { try { handler.handleResult(currentElement); // Building the next layer. for (Picker<T> picker : this.getPickers()) { Iterable<T> nexts = picker.getNexts(currentElement); // getting children. if (nexts != null) { nextLayer = Iterables.concat(nextLayer, nexts); } } } catch (CannotHandleException e) { // do nothing } catch (Exception e) { throw new CollectionAbortedException(e); } } // The current layer has been processed. Going through the next one. currentLayer = nextLayer; nextLayer = Collections.emptyList(); } }
From source file:dagger2.internal.codegen.ContributionBinding.java
/** * Returns a single {@code BindingsType} represented by a given collection of * {@code ContributionBindings} or throws an IllegalArgumentException if the given bindings * are not all of one type./*from ww w .j a v a 2s . co m*/ */ static BindingType bindingTypeFor(Iterable<? extends ContributionBinding> bindings) { checkNotNull(bindings); checkArgument(!Iterables.isEmpty(bindings), "no bindings"); Set<BindingType> types = EnumSet.noneOf(BindingType.class); for (ContributionBinding binding : bindings) { types.add(binding.bindingType()); } if (types.size() > 1) { throw new IllegalArgumentException(String.format(ErrorMessages.MULTIPLE_BINDING_TYPES_FORMAT, types)); } return Iterables.getOnlyElement(types); }
From source file:io.github.mywarp.mywarp.command.parametric.provider.WarpNameProvider.java
private boolean existsSameNameWarp(final String nameToCheck, boolean checkCaseSensitively) { if (checkCaseSensitively) { return warpManager.containsByName(nameToCheck); }/* ww w .j a v a 2 s .co m*/ return !Iterables.isEmpty(warpManager.getAll(input -> input.getName().equalsIgnoreCase(nameToCheck))); }
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 .ja va2 s . c o 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.eclipse.elk.alg.mrtree.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. * // w w w .j av a2s. c om * @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(InternalProperties.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:com.groupon.jenkins.dynamic.build.execution.DynamicMultiConfigBuildRunner.java
@Override public Result runBuild(BuildListener listener) throws InterruptedException, IOException { try {/*w w w . j a v a 2 s .co m*/ Result combinedResult = subBuildScheduler.runSubBuilds(build.getRunSubProjects(), listener); Iterable<DynamicSubProject> postBuildSubProjects = build.getPostBuildSubProjects(); if (combinedResult.equals(Result.SUCCESS) && !Iterables.isEmpty(postBuildSubProjects)) { Result runSubBuildResults = subBuildScheduler.runSubBuilds(postBuildSubProjects, listener); combinedResult = combinedResult.combine(runSubBuildResults); } build.setResult(combinedResult); dotCiPluginRunner.runPlugins(listener); return combinedResult; } finally { try { subBuildScheduler.cancelSubBuilds(listener.getLogger()); } catch (Exception e) { // There is nothing much we can do at this point LOGGER.log(Level.SEVERE, "Failed to cancel subbuilds", e); } } }
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()); }/* w w w . j a v a2 s. com*/ }
From source file:org.apache.aurora.scheduler.http.Maintenance.java
private Multimap<String, String> getTasksByHosts(StoreProvider provider, Iterable<String> hosts) { if (Iterables.isEmpty(hosts)) { return ImmutableMultimap.of(); }//from ww w.j av a 2 s .co m ImmutableSet.Builder<IScheduledTask> drainingTasks = ImmutableSet.builder(); drainingTasks.addAll( provider.getTaskStore().fetchTasks(Query.slaveScoped(hosts).byStatus(Tasks.SLAVE_ASSIGNED_STATES))); return Multimaps.transformValues(Multimaps.index(drainingTasks.build(), Tasks::scheduledToSlaveHost), Tasks::id); }
From source file:com.isotrol.impe3.freemarker.wrap.PortalObjectWrapper.java
PortalObjectWrapper(RenderContext context, Iterable<? extends PortalFreeMarkerModelFactory> factories) { this.context = checkNotNull(context, "The render context must be provided"); if (factories == null || Iterables.isEmpty(factories)) { this.factories = Arrays.asList(Factory.values()); } else {/*w ww. j av a2 s .c o m*/ this.factories = ImmutableList.<PortalFreeMarkerModelFactory>builder() .addAll(Arrays.asList(Factory.values())).addAll(factories).build(); } }