Class AbstractAsyncRepository<ID,​T>

  • Type Parameters:
    ID - the type of entity's identifier
    T - the type of entity stored in this repository

    public abstract class AbstractAsyncRepository<ID,​T>
    extends AbstractRepositoryBase<ID,​T,​AsyncNamedMap<ID,​T>>
    Abstract base class for asynchronous Coherence repository implementations.
    Since:
    21.06
    Author:
    Ryan Lubke 2021.04.08, Aleks Seovic
    • Constructor Detail

      • AbstractAsyncRepository

        public AbstractAsyncRepository()
    • Method Detail

      • save

        public CompletableFuture<T> save​(T entity)
        Store the specified entity.
        Parameters:
        entity - the entity to store
        Returns:
        the saved entity
      • saveAll

        public CompletableFuture<Void> saveAll​(Collection<? extends T> colEntities)
        Store all specified entities as a batch.
        Parameters:
        colEntities - the entities to store
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
      • saveAll

        public CompletableFuture<Void> saveAll​(Stream<? extends T> strEntities)
        Store all specified entities as a batch.
        Parameters:
        strEntities - the entities to store
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
      • get

        public CompletableFuture<T> get​(ID id)
        Return an entity with a given identifier.
        Parameters:
        id - the entity's identifier
        Returns:
        a CompletableFuture for the value to which the specified id is mapped
      • exists

        public CompletableFuture<Boolean> exists​(ID id)
        Returns true if this repository contains the entity with the specified identifier.
        Parameters:
        id - the identifier of an entity to check if it exists
        Returns:
        a CompletableFuture that will resolve to true if this repository contains the entity with the specified identifier
      • get

        public <R> CompletableFuture<R> get​(ID id,
                                            ValueExtractor<? super T,​? extends R> extractor)
        Return the value extracted from an entity with a given identifier.

        For example, you could extract Person's name attribute by calling a getter on a remote Person entity instance:

             people.get(ssn, Person::getName);
         
        You could also extract a Fragment containing the Person's name and age attributes by calling corresponding getters on the remote Person entity instance:
             Fragment<Person> person = people.get(ssn, Extractors.fragment(Person::getName, Person::getAge));
             System.out.println("name: " + person.get(Person::getName));
             System.out.println(" age: " + person.get(Person::getAge));
         
        Finally, you can also extract nested fragments:
             Fragment<Person> person = people.get(ssn,
                   Extractors.fragment(Person::getName, Person::getAge,
                                       Extractors.fragment(Person::getAddress, Address::getCity, Address::getState));
             System.out.println(" name: " + person.get(Person::getName));
             System.out.println("  age: " + person.get(Person::getAge));
        
             Fragment<Address> address = person.getFragment(Person::getAddress);
             System.out.println(" city: " + address.get(Address::getCity));
             System.out.println("state: " + address.get(Address::getState));
         
        Note that the actual extraction (via the invocation of the specified getter method) will happen on the primary owner for the specified entity, and only the extracted value will be sent over the network to the client, which can significantly reduce the amount of data transferred.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        id - the entity's identifier
        extractor - the ValueExtractor to extract value with
        Returns:
        a CompletableFuture that will resolve to the extracted value
      • getAll

        public CompletableFuture<Void> getAll​(Consumer<? super T> callback)
        Stream all entities all entities in this repository.
        Parameters:
        callback - a consumer of results as they become available
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        See Also:
        getAll()
      • getAll

        public <R> CompletableFuture<Void> getAll​(ValueExtractor<? super T,​? extends R> extractor,
                                                  BiConsumer<? super ID,​? super R> callback)
        Streams the id and the associated extracted value from all entities in the repository.
        Type Parameters:
        R - the type of the extracted values
        Parameters:
        extractor - the ValueExtractor to extract values with
        callback - a consumer of results as they become available
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        See Also:
        getAll(ValueExtractor)
      • getAll

        public <R> CompletableFuture<Void> getAll​(Collection<? extends ID> colIds,
                                                  ValueExtractor<? super T,​? extends R> extractor,
                                                  BiConsumer<? super ID,​? super R> callback)
        Stream the entities associated with the specified ids to the provided callback.
        Type Parameters:
        R - the type of the extracted values
        Parameters:
        colIds - a Collection of ids that may be present in this repository
        extractor - the ValueExtractor to extract values with
        callback - a consumer of results as they become available
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        See Also:
        getAll(Collection)
      • getAll

        public CompletableFuture<Collection<T>> getAll​(Filter<?> filter)
        Return all entities that satisfy the specified criteria.
        Parameters:
        filter - the criteria to evaluate
        Returns:
        a CompletableFuture that will resolve to all entities that satisfy the specified criteria
      • getAll

        public CompletableFuture<Void> getAll​(Filter<?> filter,
                                              Consumer<? super T> callback)
        Stream all entities that satisfy the specified criteria.
        Parameters:
        filter - the criteria to evaluate
        callback - a consumer of results as they become available
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        See Also:
        getAll(Filter)
      • getAll

        public <R> CompletableFuture<Map<ID,​R>> getAll​(Filter<?> filter,
                                                             ValueExtractor<? super T,​? extends R> extractor)
        Return a map of values extracted from a set of entities based on the specified criteria.
        Type Parameters:
        R - the type of the extracted values
        Parameters:
        filter - the criteria to use to select entities for extraction
        extractor - the ValueExtractor to extract values with
        Returns:
        a CompletableFuture that will resolve to a map of extracted values, keyed by entity id
        See Also:
        get(Object, ValueExtractor)
      • getAll

        public <R> CompletableFuture<Void> getAll​(Filter<?> filter,
                                                  ValueExtractor<? super T,​? extends R> extractor,
                                                  BiConsumer<? super ID,​? super R> callback)
        Streams the id and the associated extracted value from a set of entities based on the specified criteria.
        Type Parameters:
        R - the type of the extracted values
        Parameters:
        filter - the criteria to use to select entities for extraction
        extractor - the ValueExtractor to extract values with
        callback - a consumer of results as they become available
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        See Also:
        getAll(Filter, ValueExtractor)
      • getAllOrderedBy

        public <R extends Comparable<? super R>> CompletableFuture<Collection<T>> getAllOrderedBy​(ValueExtractor<? super T,​? extends R> orderBy)
        Return all entities in this repository, sorted using specified Comparable attribute.
        Type Parameters:
        R - the type of the extracted values
        Parameters:
        orderBy - the Comparable attribute to sort the results by
        Returns:
        a CompletableFuture that will resolve to all entities in this repository, sorted using specified Comparable attribute.
      • getAllOrderedBy

        public <R extends Comparable<? super R>> CompletableFuture<Collection<T>> getAllOrderedBy​(Filter<?> filter,
                                                                                                  ValueExtractor<? super T,​? extends R> orderBy)
        Return all entities that satisfy the specified criteria, sorted using specified Comparable attribute.
        Type Parameters:
        R - the type of the extracted values
        Parameters:
        filter - the criteria to evaluate
        orderBy - the Comparable attribute to sort the results by
        Returns:
        a CompletableFuture that will resolve to all entities that satisfy specified criteria, sorted using specified Comparable attribute.
      • update

        public <U> CompletableFuture<Void> update​(ID id,
                                                  ValueUpdater<? super T,​? super U> updater,
                                                  U value)
        Update an entity using specified updater and the new value.

        For example, you could update Person's age attribute by calling a setter on a remote Person entity instance:

             people.update(ssn, Person::setAge, 21);
         
        Note that the actual update (via the invocation of the specified setter method) will happen on the primary owner for the specified entity, and the updater will have exclusive access to an entity during the execution.
        Type Parameters:
        U - the type of value to update
        Parameters:
        id - the entity's identifier
        updater - the updater function to use
        value - the value to update entity with, which will be passed as an argument to the updater function
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
      • update

        public <U> CompletableFuture<Void> update​(ID id,
                                                  ValueUpdater<? super T,​? super U> updater,
                                                  U value,
                                                  EntityFactory<? super ID,​? extends T> factory)
        Update an entity using specified updater and the new value, and optional EntityFactory that will be used to create entity instance if it doesn't already exist in the repository.

        For example, you could update Person's age attribute by calling a setter on a remote Person entity instance:

             people.update(ssn, Person::setAge, 21, Person::new);
         
        If the person with the specified identifier does not exist, the EntityFactory will be used to create a new instance. In the example above, it will invoke a constructor on the Person class that takes identifier as an argument.

        Note that the actual update (via the invocation of the specified setter method) will happen on the primary owner for the specified entity, and the updater will have exclusive access to an entity during the execution.

        Type Parameters:
        U - the type of value to update
        Parameters:
        id - the entity's identifier
        updater - the updater function to use
        value - the value to update entity with, which will be passed as an argument to the updater function
        factory - the entity factory to use to create new entity instance
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
      • update

        public <R> CompletableFuture<R> update​(ID id,
                                               Remote.Function<? super T,​? extends R> updater)
        Update an entity using specified updater function.

        For example, you could increment Person's age attribute and return the updated Person entity:

            people.update(ssn, person ->
                {
                person.setAge(person.getAge() + 1);
                return person;
                });
         
        This variant of the update method offers ultimate flexibility, as it allows you to return any value you want as the result of the invocation, at the cost of typically slightly more complex logic at the call site.

        Note that the actual update (via the evaluation of the specified function) will happen on the primary owner for the specified entity, and the updater will have exclusive access to an entity during the execution.

        Type Parameters:
        R - the type of return value of the updater function
        Parameters:
        id - the entity's identifier
        updater - the updater function to use
        Returns:
        a CompletableFuture that will resolve to the result of updater function evaluation
      • update

        public <R> CompletableFuture<R> update​(ID id,
                                               Remote.Function<? super T,​? extends R> updater,
                                               EntityFactory<? super ID,​? extends T> factory)
        Update an entity using specified updater function, and optional EntityFactory that will be used to create entity instance if it doesn't already exist in the repository.

        For example, you could increment Person's age attribute and return the updated Person entity:

            people.update(ssn, person ->
                {
                person.setAge(person.getAge() + 1);
                return person;
                }, Person::new);
         
        If the person with the specified identifier does not exist, the EntityFactory will be used to create a new instance. In the example above, it will invoke a constructor on the Person class that takes identifier as an argument.

        This variant of the update method offers ultimate flexibility, as it allows you to return any value you want as the result of the invocation, at the cost of typically slightly more complex logic at the call site.

        Note that the actual update (via the evaluation of the specified function) will happen on the primary owner for the specified entity, and the updater will have exclusive access to an entity during the execution.

        Type Parameters:
        R - the type of return value of the updater function
        Parameters:
        id - the entity's identifier
        updater - the updater function to use
        factory - the entity factory to use to create new entity instance
        Returns:
        a CompletableFuture that will resolve to the result of updater function evaluation
      • update

        public <U,​R> CompletableFuture<R> update​(ID id,
                                                       Remote.BiFunction<? super T,​? super U,​? extends R> updater,
                                                       U value)
        Update an entity using specified updater and the new value.

        Unlike update(Object, ValueUpdater, Object), which doesn't return anything, this method is typically used to invoke "fluent" methods on the target entity that return entity itself (although they are free to return any value they want).

        For example, you could use it to add an item to the ShoppingCart entity and return the updated ShoppingCart instance in a single call:

             Item item = ...
             ShoppingCart cart = carts.update(cartId, ShoppingCart::addItem, item);
         
        Note that the actual update (via the invocation of the specified setter method) will happen on the primary owner for the specified entity, and the updater will have exclusive access to an entity during the execution.
        Type Parameters:
        U - the type of value to update
        R - the type of return value of the updater function
        Parameters:
        id - the entity's identifier
        updater - the updater function to use
        value - the value to update entity with, which will be passed as an argument to the updater function
        Returns:
        a CompletableFuture that will resolve to the result of updater function evaluation
      • update

        public <U,​R> CompletableFuture<R> update​(ID id,
                                                       Remote.BiFunction<? super T,​? super U,​? extends R> updater,
                                                       U value,
                                                       EntityFactory<? super ID,​? extends T> factory)
        Update an entity using specified updater function, and optional EntityFactory that will be used to create entity instance if it doesn't already exist in the repository.

        Unlike update(Object, ValueUpdater, Object), which doesn't return anything, this method is typically used to invoke "fluent" methods on the target entity that return entity itself (although they are free to return any value they want).

        For example, you could use it to add an item to the ShoppingCart entity and return the updated ShoppingCart instance in a single call:

             Item item = ...
             ShoppingCart cart = carts.update(cartId, ShoppingCart::addItem, item, ShoppingCart::new);
         
        If the cart with the specified identifier does not exist, the specified EntityFactory will be used to create a new instance. In the example above, it will invoke a constructor on the ShoppingCart class that takes identifier as an argument.

        Note that the actual update (via the evaluation of the specified function) will happen on the primary owner for the specified entity, and the updater will have exclusive access to an entity during the execution.

        Type Parameters:
        U - the type of value to update
        R - the type of return value of the updater function
        Parameters:
        id - the entity's identifier
        updater - the updater function to use
        value - the value to update entity with, which will be passed as an argument to the updater function
        factory - the entity factory to use to create new entity instance
        Returns:
        a CompletableFuture that will resolve to the result of updater function evaluation
      • updateAll

        public <U> CompletableFuture<Void> updateAll​(Filter<?> filter,
                                                     ValueUpdater<? super T,​? super U> updater,
                                                     U value)
        Update multiple entities using specified updater and the new value.
        Type Parameters:
        U - the type of value to update
        Parameters:
        filter - the criteria to use to select entities to update
        updater - the updater function to use
        value - the value to update each entity with, which will be passed as an argument to the updater function
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
      • updateAll

        public <R> CompletableFuture<Map<ID,​R>> updateAll​(Filter<?> filter,
                                                                Remote.Function<? super T,​? extends R> updater)
        Update multiple entities using specified updater function.
        Type Parameters:
        R - the type of return value of the updater function
        Parameters:
        filter - the criteria to use to select entities to update
        updater - the updater function to use
        Returns:
        a CompletableFuture that will resolve to a map of updater function results, keyed by entity id
      • updateAll

        public <U,​R> CompletableFuture<Map<ID,​R>> updateAll​(Filter<?> filter,
                                                                        Remote.BiFunction<? super T,​? super U,​? extends R> updater,
                                                                        U value)
        Update multiple entities using specified updater and the new value.
        Type Parameters:
        U - the type of value to update
        R - the type of return value of the updater function
        Parameters:
        filter - the criteria to use to select entities to update
        updater - the updater function to use
        value - the value to update each entity with, which will be passed as an argument to the updater function
        Returns:
        a CompletableFuture that will resolve to a map of updater function results, keyed by entity id
      • removeById

        public CompletableFuture<Boolean> removeById​(ID id)
        Remove the entity with a specified identifier.
        Parameters:
        id - the identifier of an entity to remove, if present
        Returns:
        a CompletableFuture that will resolve to true if this repository contained the specified entity
      • removeById

        public CompletableFuture<T> removeById​(ID id,
                                               boolean fReturn)
        Remove the entity with a specified identifier.
        Parameters:
        id - the identifier of an entity to remove
        fReturn - the flag specifying whether to return removed entity
        Returns:
        a CompletableFuture that will resolve to the removed entity, iff fReturn == true; null otherwise
      • remove

        public CompletableFuture<Boolean> remove​(T entity)
        Remove the specified entity.
        Parameters:
        entity - the entity to remove
        Returns:
        a CompletableFuture that will resolve to true if this repository contained the specified entity
      • remove

        public CompletableFuture<T> remove​(T entity,
                                           boolean fReturn)
        Remove the specified entity.
        Parameters:
        entity - the entity to remove
        fReturn - the flag specifying whether to return removed entity
        Returns:
        a CompletableFuture that will resolve to the removed entity, iff fReturn == true; null otherwise
      • removeAllById

        public CompletableFuture<Boolean> removeAllById​(Collection<? extends ID> colIds)
        Remove entities with the specified identifiers.
        Parameters:
        colIds - the identifiers of the entities to remove
        Returns:
        a CompletableFuture that will resolve to true if this repository changed as a result of the call
      • removeAllById

        public CompletableFuture<Map<ID,​T>> removeAllById​(Collection<? extends ID> colIds,
                                                                boolean fReturn)
        Remove entities with the specified identifiers.
        Parameters:
        colIds - the identifiers of the entities to remove
        fReturn - the flag specifying whether to return removed entity
        Returns:
        a CompletableFuture that will resolve to a map of removed entity identifiers as keys, and the removed entities as values iff fReturn == true; null otherwise
      • removeAll

        public CompletableFuture<Boolean> removeAll​(Collection<? extends T> colEntities)
        Remove the specified entities.
        Parameters:
        colEntities - the entities to remove
        Returns:
        a CompletableFuture that will resolve to true if this repository changed as a result of the call
      • removeAll

        public CompletableFuture<Map<ID,​T>> removeAll​(Collection<? extends T> colEntities,
                                                            boolean fReturn)
        Remove the specified entities.
        Parameters:
        colEntities - the entities to remove
        fReturn - the flag specifying whether to return removed entity
        Returns:
        a CompletableFuture that will resolve to a map of removed entity identifiers as keys, and the removed entities as values iff fReturn == true; null otherwise
      • removeAll

        public CompletableFuture<Boolean> removeAll​(Stream<? extends T> strEntities)
        Remove the specified entities.
        Parameters:
        strEntities - the entities to remove
        Returns:
        a CompletableFuture that will resolve to true if this repository changed as a result of the call
      • removeAll

        public CompletableFuture<Map<ID,​T>> removeAll​(Stream<? extends T> strEntities,
                                                            boolean fReturn)
        Remove the specified entities.
        Parameters:
        strEntities - the entities to remove
        fReturn - the flag specifying whether to return removed entity
        Returns:
        a CompletableFuture that will resolve to a map of removed entity identifiers as keys, and the removed entities as values iff fReturn == true; null otherwise
      • removeAll

        public CompletableFuture<Boolean> removeAll​(Filter<?> filter)
        Remove all entities based on the specified criteria.
        Parameters:
        filter - the criteria that should be used to select entities to remove
        Returns:
        a CompletableFuture that will resolve to true if this repository changed as a result of the call
      • removeAll

        public CompletableFuture<Map<ID,​T>> removeAll​(Filter<?> filter,
                                                            boolean fReturn)
        Remove all entities based on the specified criteria.
        Parameters:
        filter - the criteria that should be used to select entities to remove
        fReturn - the flag specifying whether to return removed entity
        Returns:
        a CompletableFuture that will resolve to a map of removed entity identifiers as keys, and the removed entities as values iff fReturn == true; null otherwise
      • count

        public CompletableFuture<Long> count()
        Return the number of entities in this repository.
        Returns:
        a CompletableFuture that will resolve to the number of entities in this repository
      • count

        public CompletableFuture<Long> count​(Filter<?> filter)
        Return the number of entities in this repository that satisfy specified filter.
        Parameters:
        filter - the filter to evaluate
        Returns:
        a CompletableFuture that will resolve to the number of entities in this repository that satisfy specified filter
      • max

        public CompletableFuture<Integer> max​(Remote.ToIntFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<Integer> max​(Filter<?> filter,
                                              Remote.ToIntFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<Long> max​(Remote.ToLongFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<Long> max​(Filter<?> filter,
                                           Remote.ToLongFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<Double> max​(Remote.ToDoubleFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<Double> max​(Filter<?> filter,
                                             Remote.ToDoubleFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<BigDecimal> max​(Remote.ToBigDecimalFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public CompletableFuture<BigDecimal> max​(Filter<?> filter,
                                                 Remote.ToBigDecimalFunction<? super T> extractor)
        Return the maximum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public <R extends Comparable<? super R>> CompletableFuture<R> max​(Remote.ToComparableFunction<? super T,​R> extractor)
        Return the maximum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getName
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • max

        public <R extends Comparable<? super R>> CompletableFuture<R> max​(Filter<?> filter,
                                                                          Remote.ToComparableFunction<? super T,​R> extractor)
        Return the maximum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getName
        Returns:
        a CompletableFuture that will resolve to the maximum value of the specified function
      • maxBy

        public <R extends Comparable<? super R>> CompletableFuture<Optional<T>> maxBy​(ValueExtractor<? super T,​? extends R> extractor)
        Return the entity with the maximum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the entity with the maximum value of the specified function
      • maxBy

        public <R extends Comparable<? super R>> CompletableFuture<Optional<T>> maxBy​(Filter<?> filter,
                                                                                      ValueExtractor<? super T,​? extends R> extractor)
        Return the entity with the maximum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the maximum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the entity with the maximum value of the specified function
      • min

        public CompletableFuture<Integer> min​(Remote.ToIntFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<Integer> min​(Filter<?> filter,
                                              Remote.ToIntFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<Long> min​(Remote.ToLongFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<Long> min​(Filter<?> filter,
                                           Remote.ToLongFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<Double> min​(Remote.ToDoubleFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<Double> min​(Filter<?> filter,
                                             Remote.ToDoubleFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<BigDecimal> min​(Remote.ToBigDecimalFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public CompletableFuture<BigDecimal> min​(Filter<?> filter,
                                                 Remote.ToBigDecimalFunction<? super T> extractor)
        Return the minimum value of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public <R extends Comparable<? super R>> CompletableFuture<R> min​(Remote.ToComparableFunction<? super T,​R> extractor)
        Return the minimum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getName
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • min

        public <R extends Comparable<? super R>> CompletableFuture<R> min​(Filter<?> filter,
                                                                          Remote.ToComparableFunction<? super T,​R> extractor)
        Return the minimum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getName
        Returns:
        a CompletableFuture that will resolve to the minimum value of the specified function
      • minBy

        public <R extends Comparable<? super R>> CompletableFuture<Optional<T>> minBy​(ValueExtractor<? super T,​? extends R> extractor)
        Return the entity with the minimum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the entity with the minimum value of the specified function
      • minBy

        public <R extends Comparable<? super R>> CompletableFuture<Optional<T>> minBy​(Filter<?> filter,
                                                                                      ValueExtractor<? super T,​? extends R> extractor)
        Return the entity with the minimum value of the specified function.
        Type Parameters:
        R - the type of the extracted value
        Parameters:
        filter - the entity selection criteria
        extractor - the function to determine the minimum value for; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the entity with the minimum value of the specified function
      • sum

        public CompletableFuture<Long> sum​(Remote.ToIntFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • sum

        public CompletableFuture<Long> sum​(Filter<?> filter,
                                           Remote.ToIntFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • sum

        public CompletableFuture<Long> sum​(Remote.ToLongFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • sum

        public CompletableFuture<Long> sum​(Filter<?> filter,
                                           Remote.ToLongFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • sum

        public CompletableFuture<Double> sum​(Remote.ToDoubleFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • sum

        public CompletableFuture<Double> sum​(Filter<?> filter,
                                             Remote.ToDoubleFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • sum

        public CompletableFuture<BigDecimal> sum​(Filter<?> filter,
                                                 Remote.ToBigDecimalFunction<? super T> extractor)
        Return the sum of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to sum; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the sum of the specified function
      • average

        public CompletableFuture<Double> average​(Remote.ToIntFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        extractor - the function to average; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<Double> average​(Filter<?> filter,
                                                 Remote.ToIntFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to average; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<Double> average​(Remote.ToLongFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        extractor - the function to average; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<Double> average​(Filter<?> filter,
                                                 Remote.ToLongFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to average; typically a method reference on the entity class, such as Person::getAge
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<Double> average​(Remote.ToDoubleFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        extractor - the function to average; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<Double> average​(Filter<?> filter,
                                                 Remote.ToDoubleFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to average; typically a method reference on the entity class, such as Person::getWeight
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<BigDecimal> average​(Remote.ToBigDecimalFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        extractor - the function to average; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • average

        public CompletableFuture<BigDecimal> average​(Filter<?> filter,
                                                     Remote.ToBigDecimalFunction<? super T> extractor)
        Return the average of the specified function.
        Parameters:
        filter - the entity selection criteria
        extractor - the function to average; typically a method reference on the entity class, such as Person::getSalary
        Returns:
        a CompletableFuture that will resolve to the average of the specified function
      • distinct

        public <R> CompletableFuture<Collection<? extends R>> distinct​(ValueExtractor<? super T,​? extends R> extractor)
        Return the set of distinct values for the specified extractor.
        Type Parameters:
        R - the type of extracted values
        Parameters:
        extractor - the extractor to get a value from; typically a method reference on the entity class, such as Person::getName
        Returns:
        a CompletableFuture that will resolve to a set of distinct values for the specified extractor
      • distinct

        public <R> CompletableFuture<Collection<? extends R>> distinct​(Filter<?> filter,
                                                                       ValueExtractor<? super T,​? extends R> extractor)
        Return the set of distinct values for the specified extractor.
        Type Parameters:
        R - the type of extracted values
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get a value from; typically a method reference on the entity class, such as Person::getName
        Returns:
        a CompletableFuture that will resolve to a set of distinct values for the specified extractor
      • groupBy

        public <K> CompletableFuture<Map<K,​Set<T>>> groupBy​(ValueExtractor<? super T,​? extends K> extractor)
        Return the grouping of entities by the specified extractor.
        Type Parameters:
        K - the type of extracted grouping keys
        Parameters:
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be sets of entities that match each extracted key
      • groupBy

        public <K> CompletableFuture<Map<K,​SortedSet<T>>> groupBy​(ValueExtractor<? super T,​? extends K> extractor,
                                                                        Remote.Comparator<? super T> orderBy)
        Return the grouping of entities by the specified extractor, ordered by the specified attribute within each group.
        Type Parameters:
        K - the type of extracted grouping keys
        Parameters:
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        orderBy - the Remote.Comparator to sort the results within each group by
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be sets of entities that match each extracted key
      • groupBy

        public <K> CompletableFuture<Map<K,​Set<T>>> groupBy​(Filter<?> filter,
                                                                  ValueExtractor<? super T,​? extends K> extractor)
        Return the grouping of entities by the specified extractor.
        Type Parameters:
        K - the type of extracted grouping keys
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be sets of entities that match each extracted key
      • groupBy

        public <K> CompletableFuture<Map<K,​SortedSet<T>>> groupBy​(Filter<?> filter,
                                                                        ValueExtractor<? super T,​? extends K> extractor,
                                                                        Remote.Comparator<? super T> orderBy)
        Return the grouping of entities by the specified extractor, ordered by the specified attribute within each group.
        Type Parameters:
        K - the type of extracted grouping keys
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        orderBy - the Remote.Comparator to sort the results within each group by
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be sets of entities that match each extracted key
      • groupBy

        public <K,​A,​R> CompletableFuture<Map<K,​R>> groupBy​(ValueExtractor<? super T,​? extends K> extractor,
                                                                             RemoteCollector<? super T,​A,​R> collector)
        Return the grouping of entities by the specified extractor.
        Type Parameters:
        K - the type of extracted grouping keys
        A - the type of collector's accumulator
        R - the type of collector's result
        Parameters:
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        collector - the RemoteCollector to apply to grouped entities
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be results of the specified collector for each group
        See Also:
        RemoteCollectors
      • groupBy

        public <K,​A,​R> CompletableFuture<Map<K,​R>> groupBy​(Filter<?> filter,
                                                                             ValueExtractor<? super T,​? extends K> extractor,
                                                                             RemoteCollector<? super T,​A,​R> collector)
        Return the grouping of entities by the specified extractor.
        Type Parameters:
        K - the type of extracted grouping keys
        A - the type of collector's accumulator
        R - the type of collector's result
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        collector - the RemoteCollector to apply to grouped entities
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be results of the specified collector for each group
        See Also:
        RemoteCollectors
      • groupBy

        public <K,​A,​R,​M extends Map<K,​R>> CompletableFuture<M> groupBy​(ValueExtractor<? super T,​? extends K> extractor,
                                                                                               Remote.Supplier<M> mapFactory,
                                                                                               RemoteCollector<? super T,​A,​R> collector)
        Return the grouping of entities by the specified extractor.
        Type Parameters:
        K - the type of extracted grouping keys
        A - the type of collector's accumulator
        R - the type of collector's result
        M - the type of result Map
        Parameters:
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        mapFactory - the supplier to use to create result Map
        collector - the RemoteCollector to apply to grouped entities
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be results of the specified collector for each group
        See Also:
        RemoteCollectors
      • groupBy

        public <K,​A,​R,​M extends Map<K,​R>> CompletableFuture<M> groupBy​(Filter<?> filter,
                                                                                               ValueExtractor<? super T,​? extends K> extractor,
                                                                                               Remote.Supplier<M> mapFactory,
                                                                                               RemoteCollector<? super T,​A,​R> collector)
        Return the grouping of entities by the specified extractor.
        Type Parameters:
        K - the type of extracted grouping keys
        A - the type of collector's accumulator
        R - the type of collector's result
        M - the type of result Map
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get a grouping value from; typically a method reference on the entity class, such as Person::getGender
        mapFactory - the supplier to use to create result Map
        collector - the RemoteCollector to apply to grouped entities
        Returns:
        a CompletableFuture that will resolve to a grouping of entities by the specified extractor; the keys in the returned map will be distinct values extracted by the specified extractor, and the values will be results of the specified collector for each group
        See Also:
        RemoteCollectors
      • top

        public <R extends Comparable<? super R>> CompletableFuture<List<R>> top​(ValueExtractor<? super T,​? extends R> extractor,
                                                                                int cResults)
        Return the top N highest values for the specified extractor.
        Type Parameters:
        R - the type of returned values
        Parameters:
        extractor - the extractor to get the values to compare with
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N highest values for the specified extractor
      • top

        public <R extends Comparable<? super R>> CompletableFuture<List<R>> top​(Filter<?> filter,
                                                                                ValueExtractor<? super T,​? extends R> extractor,
                                                                                int cResults)
        Return the top N highest values for the specified extractor.
        Type Parameters:
        R - the type of returned values
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get the values to compare with
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N highest values for the specified extractor
      • top

        public <R> CompletableFuture<List<R>> top​(ValueExtractor<? super T,​? extends R> extractor,
                                                  Remote.Comparator<? super R> comparator,
                                                  int cResults)
        Return the top N highest values for the specified extractor.
        Type Parameters:
        R - the type of returned values
        Parameters:
        extractor - the extractor to get the values to compare with
        comparator - the comparator to use when comparing extracted values
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N highest values for the specified extractor
      • top

        public <R> CompletableFuture<List<R>> top​(Filter<?> filter,
                                                  ValueExtractor<? super T,​? extends R> extractor,
                                                  Remote.Comparator<? super R> comparator,
                                                  int cResults)
        Return the top N highest values for the specified extractor.
        Type Parameters:
        R - the type of returned values
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get the values to compare with
        comparator - the comparator to use when comparing extracted values
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N highest values for the specified extractor
      • topBy

        public <R extends Comparable<? super R>> CompletableFuture<List<T>> topBy​(ValueExtractor<? super T,​? extends R> extractor,
                                                                                  int cResults)
        Return the top N entities with the highest values for the specified extractor.
        Type Parameters:
        R - the type of values used for comparison
        Parameters:
        extractor - the extractor to get the values to compare with
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N entities with the highest values for the specified extractor
      • topBy

        public <R extends Comparable<? super R>> CompletableFuture<List<T>> topBy​(Filter<?> filter,
                                                                                  ValueExtractor<? super T,​? extends R> extractor,
                                                                                  int cResults)
        Return the top N entities with the highest values for the specified extractor.
        Type Parameters:
        R - the type of values used for comparison
        Parameters:
        filter - the entity selection criteria
        extractor - the extractor to get the values to compare with
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N entities with the highest values for the specified extractor
      • topBy

        public CompletableFuture<List<T>> topBy​(Remote.Comparator<? super T> comparator,
                                                int cResults)
        Return the top N entities with the highest values for the specified extractor.
        Parameters:
        comparator - the comparator to use when comparing extracted values
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N entities with the highest value for the specified extractor
      • topBy

        public CompletableFuture<List<T>> topBy​(Filter<?> filter,
                                                Remote.Comparator<? super T> comparator,
                                                int cResults)
        Return the top N entities with the highest values for the specified extractor.
        Parameters:
        filter - the entity selection criteria
        comparator - the comparator to use when comparing extracted values
        cResults - the number of highest values to return
        Returns:
        a CompletableFuture that will resolve to the top N entities with the highest values for the specified extractor