List of usage examples for com.google.common.collect Iterables any
public static <T> boolean any(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:com.todoroo.astrid.tags.TagsControlSet.java
private boolean isSelected(List<TagData> selected, final String name) { return Iterables.any(selected, input -> name.equalsIgnoreCase(input.getName())); }
From source file:org.eclipse.viatra.addon.viewers.tooling.ui.views.ViewersSandboxView.java
private static Collection<IQuerySpecification<?>> getPatternsWithProperAnnotations( Collection<IQuerySpecification<?>> input) { List<IQuerySpecification<?>> res = new ArrayList<IQuerySpecification<?>>(); for (IQuerySpecification<?> p : input) { if (Iterables.any(p.getAllAnnotations(), new ViewersAnnotatedPatternTester())) { res.add(p);/*w w w.jav a 2 s. c o m*/ } } return res; }
From source file:org.caleydo.vis.lineup.model.MultiCategoricalRankColumnModel.java
@Override protected void updateMask(BitSet todo, List<IRow> data, BitSet mask) { for (int i = todo.nextSetBit(0); i >= 0; i = todo.nextSetBit(i + 1)) { Set<CATEGORY_TYPE> v = this.data.apply(data.get(i)); if ((v == null || v.isEmpty()) && filterNA) mask.set(i, false);/* w w w. j a v a2 s . c om*/ else mask.set(i, v == null ? true : Iterables.any(v, Predicates.in(selection))); } }
From source file:org.sonar.updatecenter.common.UpdateCenter.java
private boolean contain(final String pluginKey, Set<Release> installablePlugins) { return Iterables.any(installablePlugins, new Predicate<Release>() { public boolean apply(Release input) { return input.getKey().equals(pluginKey); }/*from w ww . j a v a 2s . c om*/ }); }
From source file:edu.ucsb.eucalyptus.cloud.entities.VolumeToken.java
/** * Does this token have any associated active export records * @return//w w w .j a v a 2 s .c o m * @throws EucalyptusCloudException */ public boolean hasActiveExports() throws EucalyptusCloudException { try { return Iterables.any(this.getExportRecords(), new Predicate<VolumeExportRecord>() { @Override public boolean apply(VolumeExportRecord rec) { return rec.getIsActive(); } }); } catch (Exception e) { LOG.error("Error when checking for active exports volume " + this.getVolume().getVolumeId() + " and token " + this.getToken()); throw new EucalyptusCloudException("Failed to check for valid export", e); } }
From source file:org.killbill.billing.payment.core.PaymentMethodProcessor.java
public UUID addPaymentMethod(final String paymentMethodExternalKey, final String paymentPluginServiceName, final Account account, final boolean setDefault, final PaymentMethodPlugin paymentMethodProps, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context) throws PaymentApiException { return dispatchWithExceptionHandling(account, paymentPluginServiceName, new CallableWithAccountLock<UUID, PaymentApiException>(locker, account.getId(), paymentConfig, new DispatcherCallback<PluginDispatcherReturnType<UUID>, PaymentApiException>() { @Override public PluginDispatcherReturnType<UUID> doOperation() throws PaymentApiException { PaymentMethod pm = null; try { validateUniqueExternalPaymentMethod(account.getId(), paymentPluginServiceName); pm = new DefaultPaymentMethod(paymentMethodExternalKey, account.getId(), paymentPluginServiceName, paymentMethodProps); final PaymentPluginApi pluginApi = getPaymentPluginApi( paymentPluginServiceName); pluginApi.addPaymentMethod(account.getId(), pm.getId(), paymentMethodProps, setDefault, properties, callContext); final String actualPaymentMethodExternalKey = retrieveActualPaymentMethodExternalKey( account, pm, pluginApi, properties, callContext, context); final PaymentMethodModelDao pmModel = new PaymentMethodModelDao(pm.getId(), actualPaymentMethodExternalKey, pm.getCreatedDate(), pm.getUpdatedDate(), pm.getAccountId(), pm.getPluginName(), pm.isActive()); paymentDao.insertPaymentMethod(pmModel, context); if (setDefault) { accountInternalApi.updatePaymentMethod(account.getId(), pm.getId(), context); }/* w w w .j a va2 s .c om*/ } catch (final PaymentPluginApiException e) { throw new PaymentApiException(ErrorCode.PAYMENT_ADD_PAYMENT_METHOD, account.getId(), e.getErrorMessage()); } catch (final AccountApiException e) { throw new PaymentApiException(e); } return PluginDispatcher.createPluginDispatcherReturnType(pm.getId()); } private void validateUniqueExternalPaymentMethod(final UUID accountId, final String pluginName) throws PaymentApiException { if (ExternalPaymentProviderPlugin.PLUGIN_NAME.equals(pluginName)) { final List<PaymentMethodModelDao> accountPaymentMethods = paymentDao .getPaymentMethods(context); if (Iterables.any(accountPaymentMethods, new Predicate<PaymentMethodModelDao>() { @Override public boolean apply(final PaymentMethodModelDao input) { return ExternalPaymentProviderPlugin.PLUGIN_NAME .equals(input.getPluginName()); } })) { throw new PaymentApiException( ErrorCode.PAYMENT_EXTERNAL_PAYMENT_METHOD_ALREADY_EXISTS, accountId); } } } }), uuidPluginNotificationDispatcher); }
From source file:co.paralleluniverse.strands.channels.ReceivePortGroup.java
@SuppressWarnings("element-type-mismatch") private boolean isMuted(final Port<? extends M> port, final Map<? extends ReceivePort<? extends M>, State> s) { return !s.get(port).solo && (s.get(port).mode.equals(Mix.Mode.MUTE) || (soloEffect.get().equals(Mix.SoloEffect.MUTE_OTHERS) && Iterables.any(s.values(), soloP))); }
From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.DefaultMessageCreationValidator.java
/** * Validates that a message is not created inside an interaction use. * /*from w w w. j a v a 2s .c om*/ * @return the validation that a message is not created inside an * interaction use. */ private boolean validateNotCreatingMessageInInteractionUse() { Option<Lifeline> lifeline = sequenceElementTarget.getLifeline(); Predicate<InteractionUse> interactionUseOnRealTargetLocation = new Predicate<InteractionUse>() { // Filters interaction use at the vertical position of the // source but on the targeted lifeline. public boolean apply(InteractionUse input) { return input.getVerticalRange().includes(firstClickLocation.y); } }; return lifeline.some() && !Iterables.any(lifeline.get().getAllCoveringInteractionUses(), interactionUseOnRealTargetLocation); }
From source file:org.yakindu.sct.generator.builder.SCTBuilder.java
private boolean isGenmodelForStatechart(IResource genmodelResource, final Statechart statechart) { GeneratorModel genModel = loadFromResource(genmodelResource); return genModel != null && !genModel.getEntries().isEmpty() && Iterables.any(genModel.getEntries(), new ElementRefGenerator(statechart)); }
From source file:co.paralleluniverse.strands.channels.ReceivePortGroup.java
private boolean isPaused(ReceivePort<? extends M> port, final Map<? extends ReceivePort<? extends M>, State> s) { return !s.get(port).solo && (s.get(port).mode.equals(Mix.Mode.PAUSE) || (soloEffect.get().equals(Mix.SoloEffect.PAUSE_OTHERS) && Iterables.any(s.values(), soloP))); }