public ServerSpec getSpec(final String hostname) { return Iterables.find ( specs, new Predicate<ServerSpec>() { @Override public boolean apply(ServerSpec spec) { return spec.getHostname().equals(hostname); } }, null ); }
@Override public E ceiling(E e) { return Iterables.find(unfiltered().tailSet(e, true), predicate, null); }
@Override public E higher(E e) { return Iterables.find(unfiltered().tailSet(e, false), predicate, null); }
@CheckForNull private static RuleDebt findRequirement(List<RuleDebt> requirements, final String repoKey, final String ruleKey) { return Iterables.find(requirements, new RuleDebtMatchRepoKeyAndRuleKey(repoKey, ruleKey), null); }
private Property find(String key) { return Iterables.find(list, new PropertyMatchKey(key), null); } }
@Override public NodeInfo getCurrentNodeInfo() { final List<NodeInfoModelDao> allNodes = nodeInfoDao.getAll(); final NodeInfoModelDao current = Iterables.find(allNodes, new Predicate<NodeInfoModelDao>() { @Override public boolean apply(final NodeInfoModelDao input) { return input.getNodeName().equals(CreatorName.get()); } }); return nodeTransfomer.apply(current); }
@Override protected boolean checkEntityAlreadyExists(final EntitySqlDao<TagModelDao, Tag> transactional, final TagModelDao entity, final InternalCallContext context) { return Iterables.find(transactional.getByAccountRecordId(context), new Predicate<TagModelDao>() { @Override public boolean apply(final TagModelDao existingTag) { return entity.equals(existingTag) || entity.isSame(existingTag); } }, null) != null; }
@Override protected boolean checkEntityAlreadyExists(final EntitySqlDao<CustomFieldModelDao, CustomField> transactional, final CustomFieldModelDao entity, final InternalCallContext context) { return Iterables.find(transactional.getByAccountRecordId(context), new Predicate<CustomFieldModelDao>() { @Override public boolean apply(final CustomFieldModelDao existingCustomField) { return entity.isSame(existingCustomField); } }, null) != null; }
<T extends CatalogInfo> T find(final String name, List<T> list) { return Iterables.find( list, new Predicate<T>() { @Override public boolean apply(T input) { return name.equals(OwsUtils.get(input, "name")); } }); }
private ChildData getConfigNode() { return Iterables.find ( cache.getCurrentData(), new Predicate<ChildData>() { @Override public boolean apply(ChildData data) { return ZKPaths.getNodeFromPath(data.getPath()).equals(CONFIG_NODE_NAME); } }, null ); } }
/** * Return the value for the given field or null * * @param field field to check * @return value or null */ public String getValue(final String field) { FieldValue fieldValue = Iterables.find ( fieldValues, new Predicate<FieldValue>() { @Override public boolean apply(FieldValue fv) { return fv.getField().equals(field); } }, null ); return (fieldValue != null) ? fieldValue.getValue() : null; }
public void testFind() { Iterable<String> list = newArrayList("cool", "pants"); assertEquals("cool", Iterables.find(list, Predicates.equalTo("cool"))); assertEquals("pants", Iterables.find(list, Predicates.equalTo("pants"))); try { Iterables.find(list, Predicates.alwaysFalse()); fail(); } catch (NoSuchElementException e) { } assertEquals("cool", Iterables.find(list, Predicates.alwaysTrue())); assertCanIterateAgain(list); }
private TypeValidation findByKey(String key) { TypeValidation typeValidation = Iterables.find(typeValidationList, new TypeValidationMatchKey(key), null); checkRequest(typeValidation != null, "Type '%s' is not valid.", key); return typeValidation; }
@Nonnull private PluginUpdate findPluginUpdateByKey(String key) { Optional<UpdateCenter> updateCenter = updateCenterFactory.getUpdateCenter(false); PluginUpdate pluginUpdate = MISSING_PLUGIN; if (updateCenter.isPresent()) { pluginUpdate = Iterables.find( updateCenter.get().findPluginUpdates(), new PluginKeyPredicate(key), MISSING_PLUGIN ); } if (pluginUpdate == MISSING_PLUGIN) { throw new IllegalArgumentException( format("No plugin with key '%s' or plugin '%s' is already in latest compatible version", key, key)); } return pluginUpdate; }
public void testFind_withDefault() { Iterable<String> list = Lists.newArrayList("cool", "pants"); assertEquals("cool", Iterables.find(list, Predicates.equalTo("cool"), "woot")); assertEquals("pants", Iterables.find(list, Predicates.equalTo("pants"), "woot")); assertEquals("woot", Iterables.find(list, Predicates.alwaysFalse(), "woot")); assertNull(Iterables.find(list, Predicates.alwaysFalse(), null)); assertEquals("cool", Iterables.find(list, Predicates.alwaysTrue(), "woot")); assertCanIterateAgain(list); }
@Override public E higher(E e) { return Iterables.find(unfiltered().tailSet(e, false), predicate, null); }
@Override public E ceiling(E e) { return Iterables.find(unfiltered().tailSet(e, true), predicate, null); }
public static ServerSpec findUs(Exhibitor exhibitor, List<ServerSpec> specs) { return Iterables.find(specs, ServerList.isUs(exhibitor.getThisJVMHostname()), null); }
final InternalTenantContext internalTenantContext = (InternalTenantContext) Iterables.find(ImmutableList.copyOf(args), new Predicate<Object>() { @Override public boolean apply(final Object input) {
private static Duplication duplication(List<Duplication> duplications, @Nullable final String componentKey) { return Iterables.find(duplications, input -> input != null && (componentKey == null ? input.componentDto() == null : input.componentDto() != null && componentKey.equals(input.componentDto().getDbKey()))); }