Finds a document in the collection.

@param filter      the query filter
@param resultClass the class to decode each document into
@param <ResultT>   the target document type of the iterable.
@return  a task containing the result of the find one operation
502671
public <ResultT> ResultT findOne(final Bson filter, final Class<ResultT> resultClass) {
    return proxy.findOne(filter, resultClass);
  }
838243
public DocumentT findOne(final Bson filter, final RemoteFindOptions options) {
    return proxy.findOne(filter, options);
  }
825976
@Override
    public T findOne(EntityFilter<T> filter) {
        for (T object : findAll()) {
            if (filter.accept(object)) {
                return object;
            }
        }
        return null;
    }
635735
private Filter getFilter(String layerFilter, String[] featureIds) throws GeomajasException {
		Filter filter = null;
		if (null != layerFilter) {
			filter = filterService.parseFilter(layerFilter);
		}
		if (null != featureIds) {
			Filter fidFilter = filterService.createFidFilter(featureIds);
			if (null == filter) {
				filter = fidFilter;
			} else {
				filter = filterService.createAndFilter(filter, fidFilter);
			}
		}
		return filter;
	}
199242
private <T> ResultIterable<T> findByExample(Class<?> type, Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> entity) {
        sessionContext.getCacheSynchronizationService().flush();
        EntityTypeMetadata<EntityMetadata> entityTypeMetadata = sessionContext.getMetadataProvider().getEntityMetadata(type);
        EntityDiscriminator entityDiscriminator = entityTypeMetadata.getDatastoreMetadata().getDiscriminator();
        if (entityDiscriminator == null) {
            throw new XOException("Type " + type.getName() + " has no discriminator (i.e. cannot be identified in datastore).");
        }
        ResultIterator<Entity> iterator = sessionContext.getDatastoreSession().getDatastoreEntityManager().findEntity(entityTypeMetadata, entityDiscriminator,
                entity);
        AbstractInstanceManager<EntityId, Entity> entityInstanceManager = sessionContext.getEntityInstanceManager();
        ResultIterator<T> resultIterator = new ResultIterator<T>() {

            @Override
            public boolean hasNext() {
                return iterator.hasNext();
            }

            @Override
            public T next() {
                Entity entity = iterator.next();
                return entityInstanceManager.readInstance(entity);
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("Cannot remove instance.");
            }

            @Override
            public void close() {
                iterator.close();
            }
        };
        XOTransaction xoTransaction = sessionContext.getXOTransaction();
        final ResultIterator<T> transactionalIterator = xoTransaction != null ? new TransactionalResultIterator<>(resultIterator, xoTransaction)
                : resultIterator;
        return sessionContext.getInterceptorFactory().addInterceptor(new AbstractResultIterable<T>() {
            @Override
            public ResultIterator<T> iterator() {
                return transactionalIterator;
            }
        }, ResultIterable.class);
    }
32088
public static <T extends AnnotationDesc> T findFirst(T[] original, Predicate<T> filter) {
		for (final T element : original) {
			if (filter.test(element)) {
				return element;
			}
		}
		return null;
	}
875151
def find_objects(self, ObjectClass, **kwargs):
        

        # Convert each name/value pair in '**kwargs' into a filter
        query = ObjectClass.query
        for field_name, field_value in kwargs.items():

            # Make sure that ObjectClass has a 'field_name' property
            field = getattr(ObjectClass, field_name, None)
            if field is None:
                raise KeyError("BaseAlchemyAdapter.find_first_object(): Class '%s' has no field '%s'." % (ObjectClass, field_name))

            # Add a filter to the query
            query = query.filter(field==field_value)

        # Execute query
        return query.all()
658814
function onFilterResults(e) {
    var frag         = Y.one(Y.config.doc.createDocumentFragment()),
        resultNode   = getFilterResultNode(),
        typePlural   = filter.get('queryType'),
        typeSingular = typePlural === 'classes' ? 'class' : 'module';

    if (e.results.length) {
        YArray.each(e.results, function (result) {
            frag.append(Lang.sub(LIST_ITEM_TEMPLATE, {
                rootPath    : APIList.rootPath,
                displayName : filter.getDisplayName(result.highlighted),
                name        : result.text,
                typePlural  : typePlural,
                typeSingular: typeSingular
            }));
        });
    } else {
        frag.append(
            '<li class="message">' +
                'No ' + typePlural + ' found.' +
            '</li>'
        );
    }

    resultNode.empty(true);
    resultNode.append(frag);

    focusManager.refresh();
}
1349308
public List<Class<?>> scanClasses(Predicate<String> filter)
    {
        List<Class<?>> discoveredClasses = new ArrayList<>(128);

        // For each Forge addon...
        for (Addon addon : furnace.getAddonRegistry().getAddons(AddonFilters.allStarted()))
        {
            List<String> discoveredFileNames = filterAddonResources(addon, filter);

            // Then try to load the classes.
            for (String discoveredFilename : discoveredFileNames)
            {
                String clsName = PathUtil.classFilePathToClassname(discoveredFilename);
                try
                {
                    Class<?> clazz = addon.getClassLoader().loadClass(clsName);
                    discoveredClasses.add(clazz);
                }
                catch (ClassNotFoundException ex)
                {
                    LOG.log(Level.WARNING, "Failed to load class for name '" + clsName + "':\n" + ex.getMessage(), ex);
                }
            }
        }
        return discoveredClasses;
    }
212175
public Query<S> query(String filter) throws FetchException {
        synchronized (mStringToQuery) {
            Query<S> query = mStringToQuery.get(filter);
            if (query == null) {
                if (filter == null) {
                    throw new IllegalArgumentException("Query filter must not be null");
                }
                query = query(Filter.filterFor(mType, filter), null);
                mStringToQuery.put(filter, query);
            }
            return query;
        }
    }
350258
@Override
    public Object find(Class entityClass, Object key)
    {

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        JsonDocument doc;
        String id = generateJsonDocId(entityMetadata.getTableName(), key.toString());
        doc = bucket.get(id);
        LOGGER.debug("Found result for ID : " + key.toString() + " in the " + bucket.name() + " Bucket");

        if (doc == null)
        {
            return null;
        }
        else
        {
            MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                    .getMetamodel(entityMetadata.getPersistenceUnit());
            EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());
            return handler.getEntityFromDocument(entityClass, doc.content(), entityType);
        }
    }
296822
public TypedQuery<T> select(Filter filter, OrderBy orderBy) {
        CriteriaQuery<T> query = cb.createQuery(getEntityClass());
        Root<T> from = query.from(getEntityClass());

        CriteriaMapper criteriaMapper = new CriteriaMapper(from, cb);

        if (orderBy != null) {
            query.orderBy(criteriaMapper.create(orderBy));
        }
        if (filter != null) {
            query.where(criteriaMapper.create(filter));
        }

        return getEntityManager().createQuery(query);
    }
322142
public Query<S> query(Filter<S> filter, FilterValues<S> values, OrderingList<S> ordering)
        throws FetchException
    {
        return query(filter, values, ordering, null);
    }
1186576
public static <T> Iterable<T> filter(final Iterable<T> sequence,
                                         final Predicate<? super T> filter) {
        return new Iterable<T>() {
            @Override
            public Iterator<T> iterator() {
                return new FilteringIterator<T>(sequence.iterator(), filter);
            }
        };
    }
811113
public T filter(@NonNull SerializablePredicate<? super HString> filter) {
      this.filter = filter;
      return Cast.as(this);
   }
22780
public Query<S> query(Filter<S> filter) throws FetchException {
        return query(filter, null);
    }
223493
private List<Object[]> getDataListByFilter(DataProviderFilter dataFilter) {

        logger.entering(dataFilter);
        List<Object[]> allObjs = new ArrayList<>();
        if ((null == resource.getCls()) && (null != resource.getXpathMap())) {
            Document doc = getDocument();
            for (Entry<String, Class<?>> entry : resource.getXpathMap().entrySet()) {
                String xml = getFilteredXml(doc, entry.getKey());
                List<?> objectList = loadDataFromXml(xml, entry.getValue());
                List<Object[]> singleResourceObjs = DataProviderHelper.filterToListOfObjects(objectList, dataFilter);
                allObjs.addAll(singleResourceObjs);
            }
        } else {
            List<?> objectList = loadDataFromXmlFile();
            allObjs = DataProviderHelper.filterToListOfObjects(objectList, dataFilter);
        }
        logger.exiting(allObjs);

        return allObjs;
    }