List of usage examples for com.google.common.collect Iterables isEmpty
public static boolean isEmpty(Iterable<?> iterable)
From source file:org.apache.beam.sdk.util.state.CopyOnAccessInMemoryStateInternals.java
public boolean isEmpty() { return Iterables.isEmpty(table.values()); }
From source file:com.palantir.common.collect.IterableView.java
public boolean isEmpty() { return Iterables.isEmpty(delegate()); }
From source file:org.apache.abdera2.common.http.EntityTag.java
private static boolean empty(Iterable<EntityTag> tags) { return Iterables.isEmpty(tags); }
From source file:org.obm.sync.resource.ResourceServlet.java
@VisibleForTesting String getResourceICS(String resourceEmail, SyncRange syncRange) throws ServerFault { Collection<Event> resourceEvents = calendarBinding.getResourceEvents(resourceEmail, new Date(), syncRange); if (Iterables.isEmpty(resourceEvents)) { return null; }//from w ww . j a v a2 s. com return this.ical4jHelper.buildIcsWithTimeZoneOnDtStart(null, resourceEvents, null); }
From source file:org.eclipse.sirius.diagram.ui.internal.edit.policies.RegionCollapseAwarePropertyHandlerEditPolicy.java
private Command getLayoutConstraintsCommand(boolean collapsed, Command initialCommand) { if (getHost() instanceof IResizableCompartmentEditPart && getHost().getParent() instanceof AbstractDiagramElementContainerEditPart) { AbstractDiagramElementContainerEditPart regionPart = (AbstractDiagramElementContainerEditPart) getHost() .getParent();/*from w ww . j av a 2 s. co m*/ View notationView = regionPart.getNotationView(); if (notationView instanceof Node && ((Node) notationView).getLayoutConstraint() instanceof Size && notationView.getElement() instanceof DDiagramElementContainer) { TransactionalEditingDomain editingDomain = getEditingDomain(); CompositeTransactionalCommand ctc = new CompositeTransactionalCommand(editingDomain, collapsed ? Messages.RegionCollapseAwarePropertyHandlerEditPolicy_collapseRegionCommandLabel : Messages.RegionCollapseAwarePropertyHandlerEditPolicy_expandRegionCommandLabel); Command result = new ICommandProxy(ctc); if (initialCommand != null) { ctc.add(new CommandProxy(initialCommand)); } Size size = (Size) ((Node) notationView).getLayoutConstraint(); DDiagramElementContainer ddec = (DDiagramElementContainer) notationView.getElement(); Iterable<AbsoluteBoundsFilter> boundsFilters = Iterables.filter(ddec.getGraphicalFilters(), AbsoluteBoundsFilter.class); AbsoluteBoundsFilter expandedBoundsMarker = Iterables.isEmpty(boundsFilters) ? null : boundsFilters.iterator().next(); // Update GMF size Dimension newGmfSize = new Dimension(size.getWidth(), size.getHeight()); int parentStackDirection = regionPart.getParentStackDirection(); if (parentStackDirection == PositionConstants.NORTH_SOUTH) { if (!collapsed) { newGmfSize.setHeight(expandedBoundsMarker == null ? -1 : expandedBoundsMarker.getHeight()); } else if (size.getHeight() != -1) { newGmfSize.setHeight(LayoutUtils.COLLAPSED_VERTICAL_REGION_HEIGHT); } } else if (parentStackDirection == PositionConstants.EAST_WEST) { if (!collapsed) { newGmfSize.setWidth(expandedBoundsMarker == null ? -1 : expandedBoundsMarker.getWidth()); } else if (!isTruncatedLabel(regionPart)) { // Change the GMF width only when label is not truncated // to avoid to have a collapsed Region bigger than the // expanded size (resized by the user). // Do not specify a collapsed width as it will depend on // the label size. newGmfSize.setWidth(-1); } } SetBoundsCommand setBoundsCommand = new SetBoundsCommand(editingDomain, Messages.RegionCollapseAwarePropertyHandlerEditPolicy_gmfSizeUpdateCommandLabel, new EObjectAdapter(notationView), newGmfSize); ctc.add(setBoundsCommand); // Remember expanded size: create/update/remove an // AbsoluteBoundsFilter marker on the DDiagramElement. if (collapsed) { if (expandedBoundsMarker != null) { ctc.add(new GMFCommandWrapper(editingDomain, new SetCommand(editingDomain, expandedBoundsMarker, DiagramPackage.eINSTANCE.getAbsoluteBoundsFilter_Height(), size.getHeight()))); ctc.add(new GMFCommandWrapper(editingDomain, new SetCommand(editingDomain, expandedBoundsMarker, DiagramPackage.eINSTANCE.getAbsoluteBoundsFilter_Width(), size.getWidth()))); } else { expandedBoundsMarker = DiagramFactory.eINSTANCE.createAbsoluteBoundsFilter(); expandedBoundsMarker.setHeight(size.getHeight()); expandedBoundsMarker.setWidth(size.getWidth()); ctc.add(new GMFCommandWrapper(editingDomain, new AddCommand(editingDomain, ddec.getGraphicalFilters(), expandedBoundsMarker))); } } else if (expandedBoundsMarker != null) { ctc.add(new GMFCommandWrapper(editingDomain, new RemoveCommand(editingDomain, ddec.getGraphicalFilters(), expandedBoundsMarker))); } return result; } } return initialCommand; }
From source file:org.apache.cassandra.db.lifecycle.View.java
static Function<View, View> updateCompacting(final Set<SSTableReader> unmark, final Iterable<SSTableReader> mark) { if (unmark.isEmpty() && Iterables.isEmpty(mark)) return Functions.identity(); return new Function<View, View>() { public View apply(View view) { assert all(mark, Helpers.idIn(view.sstablesMap)); return new View(view.liveMemtables, view.flushingMemtables, view.sstablesMap, replace(view.compacting, unmark, mark), view.intervalTree); }//from ww w. j a v a2 s .co m }; }
From source file:com.facebook.buck.testutil.FakeProjectFilesystem.java
@Override public void writeLinesToPath(Iterable<String> lines, Path path) { StringBuilder builder = new StringBuilder(); if (!Iterables.isEmpty(lines)) { Joiner.on('\n').appendTo(builder, lines); builder.append('\n'); }//from ww w . j ava 2 s .c o m writeContentsToPath(builder.toString(), path); }
From source file:org.apache.brooklyn.core.typereg.BasicBrooklynTypeRegistry.java
@SuppressWarnings("deprecation") private Maybe<RegisteredType> getSingle(String symbolicNameOrAliasIfNoVersion, final String versionFinal, final RegisteredTypeLoadingContext contextFinal) { RegisteredTypeLoadingContext context = contextFinal; if (context == null) context = RegisteredTypeLoadingContexts.any(); String version = versionFinal; if (version == null) version = BrooklynCatalog.DEFAULT_VERSION; if (!BrooklynCatalog.DEFAULT_VERSION.equals(version)) { // normal code path when version is supplied Maybe<RegisteredType> type = getExactWithoutLegacyCatalog(symbolicNameOrAliasIfNoVersion, version, context);/* ww w .ja va 2 s . co m*/ if (type.isPresent()) return type; } if (BrooklynCatalog.DEFAULT_VERSION.equals(version)) { // alternate code path, if version blank or default Iterable<RegisteredType> types = getMatching( Predicates.and(RegisteredTypePredicates.symbolicName(symbolicNameOrAliasIfNoVersion), RegisteredTypePredicates.satisfies(context))); if (Iterables.isEmpty(types)) { // look for alias if no exact symbolic name match AND no version is specified types = getMatching(Predicates.and(RegisteredTypePredicates.alias(symbolicNameOrAliasIfNoVersion), RegisteredTypePredicates.satisfies(context))); // if there are multiple symbolic names then throw? Set<String> uniqueSymbolicNames = MutableSet.of(); for (RegisteredType t : types) { uniqueSymbolicNames.add(t.getSymbolicName()); } if (uniqueSymbolicNames.size() > 1) { String message = "Multiple matches found for alias '" + symbolicNameOrAliasIfNoVersion + "': " + uniqueSymbolicNames + "; " + "refusing to select any."; log.warn(message); return Maybe.absent(message); } } if (!Iterables.isEmpty(types)) { RegisteredType type = RegisteredTypes.getBestVersion(types); if (type != null) return Maybe.of(type); } } // missing case is to look for exact version in legacy catalog CatalogItem<?, ?> item = mgmt.getCatalog().getCatalogItem(symbolicNameOrAliasIfNoVersion, version); if (item != null) return Maybe.of(RegisteredTypes.CI_TO_RT.apply(item)); return Maybe.absent("No matches for " + symbolicNameOrAliasIfNoVersion + (versionFinal != null ? ":" + versionFinal : "") + (contextFinal != null ? " (" + contextFinal + ")" : "")); }
From source file:com.vmware.appfactory.taskqueue.tasks.state.tasks.FeedConvertTask.java
private static boolean appHasTasks(TaskQueue taskQueue, final HasId app) { return !Iterables.isEmpty(taskQueue.findActiveTasksForApp(app.getId())); }
From source file:com.crystal.flexin.record.SmartPoster.java
/** * Returns the first element of {@code elements} which is an instance of * {@code type}, or {@code null} if no such element exists. *///from w ww .java 2 s. c o m private static <T> T getFirstIfExists(Iterable<?> elements, Class<T> type) { Iterable<T> filtered = Iterables.filter(elements, type); T instance = null; if (!Iterables.isEmpty(filtered)) { instance = Iterables.get(filtered, 0); } return instance; }