List of usage examples for com.google.common.collect Iterables isEmpty
public static boolean isEmpty(Iterable<?> iterable)
From source file:com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService.java
@Override public Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstBatchForRanges( String tableName, Iterable<RangeRequest> rangeRequests, long timestamp) { if (Iterables.isEmpty(rangeRequests)) { return ImmutableMap.of(); }/* w w w. j ava2 s .com*/ return delegate.getFirstBatchForRanges(tableName, rangeRequests, timestamp); }
From source file:org.apache.flex.compiler.internal.targets.RandoriTarget.java
@Override public IRandoriApplication build(Collection<ICompilerProblem> problems) { buildStarted();//from w w w . j ava 2 s. co m try { Iterable<ICompilerProblem> fatalProblems = getFatalProblems(); if (!Iterables.isEmpty(fatalProblems)) { Iterables.addAll(problems, fatalProblems); return null; } Set<ICompilationUnit> compilationUnitSet = new HashSet<ICompilationUnit>(); Target.RootedCompilationUnits rootedCompilationUnits = getRootedCompilationUnits(); Iterables.addAll(problems, rootedCompilationUnits.getProblems()); compilationUnitSet.addAll(rootedCompilationUnits.getUnits()); // multithreaded parse, ast, scope, definition creation buildAndCollectProblems(compilationUnitSet, problems); List<ICompilationUnit> units = new ArrayList<ICompilationUnit>(); // collect explicit and dependent classes if (collectIncrementalUnits && roots != null) { for (ICompilationUnit unit : roots) { Set<ICompilationUnit> set = project.getDirectReverseDependencies(unit, DependencyTypeSet.allOf()); for (ICompilationUnit sub : set) { units.add(sub); getTargetSettgins().addIncrementalFile(sub.getAbsoluteFilename()); } units.add(unit); getTargetSettgins().addIncrementalFile(unit.getAbsoluteFilename()); } collectIncrementalUnits = false; } else { units = project.getReachableCompilationUnitsInSWFOrder(rootedCompilationUnits.getUnits()); } IRandoriApplication application = initializeApplication(units); return application; } catch (BuildCanceledException bce) { return null; } catch (InterruptedException ie) { return null; } finally { buildFinished(); } }
From source file:org.xpect.model.XpectFileImplCustom.java
@Override public boolean isIgnore() { return !Iterables.isEmpty(Iterables.filter(getMembers(), XpectIgnore.class)); }
From source file:org.eclipse.sirius.diagram.ui.business.internal.query.RequestQuery.java
/** * Checks if the current {@link Request} request is about a GMF Note drop. * /*from w w w . j a va 2 s .c o m*/ * @return true if the current {@link Request} request is about a GMF Note * drop */ public boolean isNoteDropRequest() { boolean isNoteDropRequest = false; if (RequestConstants.REQ_ADD.equals(request.getType()) && request instanceof GroupRequest) { GroupRequest groupRequest = (GroupRequest) request; isNoteDropRequest = !Iterables .isEmpty(Iterables.filter(groupRequest.getEditParts(), NoteEditPart.class)); } return isNoteDropRequest; }
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
private boolean hasEmptyAttributes(Attributable attributable) { return Iterables.isEmpty(attributable.getKeyAttributes()); }
From source file:com.vmware.appfactory.push.PushController.java
/** * On connection, produces a list of tasks. * If not tasks are available, produces the string "NO_TASKS". * * Afterwards, the connection will remain open, sending events about each * change to the task queue.// w ww . j a va2s . co m * @param event supplied by the Atmosphere servlet. Used to broadcast * events to the client. * * @throws IOException * If the response could not be serialized. * * @throws InterruptedException * If we are blocked while writing responses. */ @ResponseBody @RequestMapping(value = "/conversion-tasks-comet", method = RequestMethod.GET) public void getConversionTasksComet(final AtmosphereResource<HttpServletRequest, HttpServletResponse> event) throws IOException, InterruptedException { initializeBroadcaster(); // note: calling setScope() will CHANGE the value returned by getBroadcaster() ! event.getBroadcaster().setScope(Broadcaster.SCOPE.REQUEST); final Broadcaster localBroadcaster = event.getBroadcaster(); // synchronize on "event" to block other updates from being sent until we // send out our task list. boolean acquired = broadcastSemaphore.tryAcquire(20, TimeUnit.SECONDS); if (!acquired) { throw new IllegalStateException("Could not get broadcast semaphore"); } try { event.suspend(); taskEventBroadcaster.addAtmosphereResource(event); // spit out a break in between the atmosphere header and the first line, // so that the client can split messages apart. localBroadcaster.broadcast("\n\n"); Iterable<TaskState> tasks = _conversionsQueue.getAllTasks(); if (Iterables.isEmpty(tasks)) { localBroadcaster.broadcast("{\"type\":\"NO-TASKS\"}\n\n"); } for (TaskState state : tasks) { String message = mapper.writeValueAsString(TaskEvent.newTaskAdded(state)); localBroadcaster.broadcast(message + "\n\n"); } } finally { broadcastSemaphore.release(); } }
From source file:org.eclipse.papyrus.uml.diagram.activity.listeners.InInterruptibleActivityRegionListener.java
/** * Get the list of all starting or ending Interruptible Edge wich are related to this {@link ActivityNode} and its descendant. * Those Iterable can be filled with null elements so test each element for null * //from ww w. java 2s . c o m * @param node * @return */ public Iterator<Iterable<ActivityEdge>> getActivityEdgeImpactedWithThisChange(ActivityNode node) { Iterator<Iterable<ActivityEdge>> activityEdges = Iterators.transform( Iterators.concat(Collections.singleton(node).iterator(), node.eAllContents()), new Function<EObject, Iterable<ActivityEdge>>() { public Iterable<ActivityEdge> apply(EObject from) { if (from instanceof ActivityNode) { ActivityNode activityNode = (ActivityNode) from; Iterable<ActivityEdge> incomingInterruptibleEdge = Iterables .filter(activityNode.getIncomings(), new Predicate<EObject>() { public boolean apply(EObject input) { if (input instanceof ActivityEdge) { return ((ActivityEdge) input).getInterrupts() != null; } return false; } }); Iterable<ActivityEdge> outcomingEdgeInterruptibleEdge = Iterables .filter(activityNode.getOutgoings(), new Predicate<EObject>() { public boolean apply(EObject input) { if (input instanceof ActivityEdge) { return ((ActivityEdge) input).getInterrupts() != null; } return false; } }); Iterable<ActivityEdge> allInterruptibleEdge = Iterables .concat(outcomingEdgeInterruptibleEdge, incomingInterruptibleEdge); if (!Iterables.isEmpty(allInterruptibleEdge)) { return allInterruptibleEdge; } } return null; } }); return activityEdges; }
From source file:org.eclipse.xtext.graphview.behavior.visibility.RevealEditPolicy.java
protected void showFeedback(RevealRequest revealRequest, RevealedEditPartMap revealedEditPartMap) { Iterable<IInstanceModelEditPart> layoutables = revealedEditPartMap.getLayoutables(); if (!Iterables.isEmpty(layoutables)) { double angle = revealRequest.getMouseAngle(); int numElements = Iterables.size(layoutables); double deltaAngle = 2 * Math.PI / numElements; IFigure hostFigure = ((GraphicalEditPart) getHost()).getFigure(); Point center = hostFigure.getBounds().getCenter(); if (hostFigure.getParent() != null) hostFigure.getParent().translateToAbsolute(center); double centerDist = revealRequest.getMouseDistance(); for (IInstanceModelEditPart layoutable : layoutables) { if (!revealRequest.isSelected(layoutable)) { IFigure figure = layoutable.getFigure(); Point newCenter = new Point(center); Dimension figureSize = figure.getSize(); newCenter.translate((int) (Math.cos(angle) * centerDist), (int) (Math.sin(angle) * centerDist)); newCenter.translate(-figureSize.width / 2, -figureSize.height / 2); if (figure.getParent() != null) { figure.getParent().translateToRelative(newCenter); }/*from w w w . jav a2 s . c om*/ figure.setBounds(new Rectangle(newCenter.x, newCenter.y, figureSize.width, figureSize.height)); } angle += deltaAngle; } for (IInstanceModelEditPart layoutable : layoutables) { boolean isSelected = revealRequest.isSelected(layoutable); layoutable.setTransparent(!isSelected); for (IInstanceModelEditPart secondary : revealedEditPartMap.getSecondaries(layoutable)) secondary.setTransparent(!isSelected); } } }
From source file:com.google.devtools.build.lib.worker.WorkerSpawnRunner.java
private SpawnResult actuallyExec(Spawn spawn, SpawnExecutionPolicy policy) throws ExecException, IOException, InterruptedException { if (Iterables.isEmpty(spawn.getToolFiles())) { throw new UserExecException(String.format(ERROR_MESSAGE_PREFIX + REASON_NO_TOOLS, spawn.getMnemonic())); }/*from w w w. j a v a 2 s . com*/ // We assume that the spawn to be executed always gets at least one @flagfile.txt or // --flagfile=flagfile.txt argument, which contains the flags related to the work itself (as // opposed to start-up options for the executed tool). Thus, we can extract those elements from // its args and put them into the WorkRequest instead. List<String> flagFiles = new ArrayList<>(); ImmutableList<String> workerArgs = splitSpawnArgsIntoWorkerArgsAndFlagFiles(spawn, flagFiles); ImmutableMap<String, String> env = spawn.getEnvironment(); ActionInputFileCache inputFileCache = policy.getActionInputFileCache(); SortedMap<PathFragment, HashCode> workerFiles = WorkerFilesHash.getWorkerFilesWithHashes(spawn, policy.getArtifactExpander(), policy.getActionInputFileCache()); HashCode workerFilesCombinedHash = WorkerFilesHash.getCombinedHash(workerFiles); Map<PathFragment, Path> inputFiles = SandboxHelpers.getInputFiles(spawn, policy, execRoot); Set<PathFragment> outputFiles = SandboxHelpers.getOutputFiles(spawn); WorkerKey key = new WorkerKey(workerArgs, env, execRoot, spawn.getMnemonic(), workerFilesCombinedHash, workerFiles, inputFiles, outputFiles, policy.speculating()); WorkRequest workRequest = createWorkRequest(spawn, policy, flagFiles, inputFileCache); long startTime = System.currentTimeMillis(); WorkResponse response = execInWorker(key, workRequest, policy); Duration wallTime = Duration.ofMillis(System.currentTimeMillis() - startTime); FileOutErr outErr = policy.getFileOutErr(); response.getOutputBytes().writeTo(outErr.getErrorStream()); return new SpawnResult.Builder().setExitCode(response.getExitCode()).setStatus(SpawnResult.Status.SUCCESS) .setWallTime(wallTime).build(); }
From source file:org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefPath.java
/** * Create a child path based on concatenation of this path and a relative * path./*from w w w .ja va2s .c o m*/ * * @param relative * Relative path * @return A new child path */ public LeafRefPath createChild(final Iterable<QNameWithPredicate> relative) { if (Iterables.isEmpty(relative)) { return this; } LeafRefPath parent = this; for (QNameWithPredicate qname : relative) { parent = parent.createInstance(parent, qname); } return parent; }