List of usage examples for com.google.common.collect Iterables find
@Nullable public static <T> T find(Iterable<? extends T> iterable, Predicate<? super T> predicate, @Nullable T defaultValue)
From source file:com.netflix.exhibitor.core.config.zookeeper.ZookeeperConfigProvider.java
private ChildData getConfigNode() { return Iterables.find(cache.getCurrentData(), new Predicate<ChildData>() { @Override//from w ww . j a va 2s. co m public boolean apply(ChildData data) { return ZKPaths.getNodeFromPath(data.getPath()).equals(CONFIG_NODE_NAME); } }, null); }
From source file:org.dcache.srm.request.HashtableRequestCredentialStorage.java
@Override public RequestCredential getRequestCredential(String name, String role) { return Iterables.find(store.values(), isMatching(name, role), null); }
From source file:org.solovyev.android.messenger.chats.BaseChatsAdapter.java
@Nullable protected ChatListItem findInAllElements(@Nonnull User user, @Nonnull Chat chat) { return Iterables.find(getAllElements(), Predicates.<ChatListItem>equalTo(ChatListItem.newEmpty(user, chat)), null);//from w ww. j a v a 2 s. co m }
From source file:me.emily.irc.io.ServerConnection.java
public Module findModule(String id) { Module mod = Iterables.find(modules, compose(equalTo(id), Module.IDAccessor.instance), null); return mod; }
From source file:org.polarsys.reqcycle.traceability.types.impl.ConfigurationProvider.java
private Configuration doGetConfiguration(final String id) { TypeConfigContainer container = doGetContainer(); Configuration conf = Iterables.find(container.getConfigurations(), new Predicate<Configuration>() { public boolean apply(Configuration conf) { return Objects.equal(conf.getName(), id); }/*from w w w . j av a 2s . c o m*/ }, null); return conf; }
From source file:org.eclipse.emf.compare.uml2.internal.postprocessor.extension.sequence.UMLIntervalConstraintChangeFactory.java
/** * {@inheritDoc}// ww w. java2s .c o m * * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse.emf.compare.Diff) */ @Override protected EObject getDiscriminant(Diff input) { return Iterables.find(getDiscriminants(input), instanceOf(IntervalConstraint.class), null); }
From source file:ee.ria.xroad.proxy.messagelog.SoapMessageBodyManipulator.java
/** * Takes one ClientId object, and searches whether it is in searched group of ClientIds * @param searchParam ClientId to search * @param searched collection to search from * @return true if ClientId is in the collection *///from w ww . j av a 2 s. co m public boolean isClientInCollection(ClientId searchParam, Iterable<ClientId> searched) { ClientId searchResult = Iterables.find(searched, input -> (input.memberEquals(searchParam) && Objects.equals(input.getSubsystemCode(), searchParam.getSubsystemCode())), null); return (searchResult != null); }
From source file:org.dcache.srm.request.HashtableRequestCredentialStorage.java
@Override public RequestCredential getRequestCredential(String name) { return Iterables.find(store.values(), c -> c.getCredentialName().equals(name), null); }
From source file:org.dbasu.robomvvm.componentmodel.PropertyManager.java
void setProperty(final Object targetObject, String name, final Object value) { Class targetType = targetObject.getClass(); final PropertyDescriptor desc = getPropertyDescriptor(targetType, name); if (desc == null || desc.setters.size() == 0) { throw new RuntimeException( "No Settable Property By Name " + name + " Found In Class " + targetType.getName()); }//from w ww.j a v a2 s . co m final Class valueClass = value.getClass(); final Method setter = Iterables.find(desc.setters, new Predicate<Method>() { @Override public boolean apply(Method m) { return ClassUtils.isAssignable(valueClass, m.getParameterTypes()[0], true); } }, null); if (setter == null) { throw new RuntimeException("Type Mismatch: Can Not Assign Value Of Type " + valueClass.getName() + " To Property " + name + " In Class " + targetType.getName()); } if (targetObject instanceof View) { Activity activity = (Activity) ((View) targetObject).getContext(); activity.runOnUiThread(new Runnable() { @Override public void run() { reallySetProperty(setter, targetObject, value); } }); } else { reallySetProperty(setter, targetObject, value); } }
From source file:gov.nih.nci.firebird.selenium2.pages.components.tags.CommentsTag.java
private static WebElement getCommentsDiv(final WebDriver driver) { List<WebElement> commentsDivs = driver.findElements(By.id(COMMENTS_DIV_ID)); return Iterables.find(commentsDivs, new Predicate<WebElement>() { @Override/*w ww . jav a2s .c om*/ public boolean apply(WebElement div) { return div.isDisplayed(); } }, null); }