All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.ArangoIterable Maven / Gradle / Ivy

There is a newer version: 7.15.0
Show newest version
/*
 * DISCLAIMER
 *
 * Copyright 2018 ArangoDB GmbH, Cologne, Germany
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Copyright holder is ArangoDB GmbH, Cologne, Germany
 */

package com.arangodb;

import java.util.Collection;

/**
 * @author Mark Vollmary
 */
public interface ArangoIterable extends Iterable {

    @Override
    ArangoIterator iterator();

    /**
     * Performs the given action for each element of the {@code ArangoIterable}
     *
     * @param action a action to perform on the elements
     */
    void foreach(Consumer action);

    /**
     * Returns a {@code ArangoIterable} consisting of the results of applying the given function to the elements of this
     * {@code ArangoIterable}.
     *
     * @param mapper a function to apply to each element
     * @return the new {@code ArangoIterable}
     */
     ArangoIterable map(Function mapper);

    /**
     * Returns a {@code ArangoIterable} consisting of the elements of this {@code ArangoIterable} that match the given
     * predicate.
     *
     * @param predicate a predicate to apply to each element to determine if it should be included
     * @return the new {@code ArangoIterable}
     */
    ArangoIterable filter(Predicate predicate);

    /**
     * Returns the first element or {@code null} if no element exists.
     *
     * @return first element or {@code null}
     */
    T first();

    /**
     * Returns the count of elements of this {@code ArangoIterable}.
     *
     * @return the count of elements
     */
    long count();

    /**
     * Returns whether any elements of this {@code ArangoIterable} match the provided predicate.
     *
     * @param predicate a predicate to apply to elements of this {@code ArangoIterable}
     * @return {@code true} if any elements of the {@code ArangoIterable} match the provided predicate, otherwise
     * {@code false}
     */
    boolean anyMatch(Predicate predicate);

    /**
     * Returns whether all elements of this {@code ArangoIterable} match the provided predicate.
     *
     * @param predicate a predicate to apply to elements of this {@code ArangoIterable}
     * @return {@code true} if all elements of the {@code ArangoIterable} match the provided predicate, otherwise
     * {@code false}
     */
    boolean allMatch(Predicate predicate);

    /**
     * Returns whether no elements of this {@code ArangoIterable} match the provided predicate.
     *
     * @param predicate a predicate to apply to elements of this {@code ArangoIterable}
     * @return {@code true} if no elements of the {@code ArangoIterable} match the provided predicate, otherwise
     * {@code false}
     */
    boolean noneMatch(Predicate predicate);

    /**
     * Iterates over all elements of this {@code ArangoIterable} and adds each to the given target.
     *
     * @param target the collection to insert into
     * @return the filled target
     */
    > R collectInto(R target);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy