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

io.micronaut.data.repository.jpa.reactive.ReactiveStreamsJpaSpecificationExecutor Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2017-2021 original authors
 *
 * 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
 *
 * https://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.
 */
package io.micronaut.data.repository.jpa.reactive;

import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.data.model.Page;
import io.micronaut.data.model.Pageable;
import io.micronaut.data.model.Sort;
import io.micronaut.data.repository.jpa.criteria.DeleteSpecification;
import io.micronaut.data.repository.jpa.criteria.PredicateSpecification;
import io.micronaut.data.repository.jpa.criteria.QuerySpecification;
import io.micronaut.data.repository.jpa.criteria.UpdateSpecification;
import org.reactivestreams.Publisher;

/**
 * Interface representing reactive streams version of {@link io.micronaut.data.repository.jpa.JpaSpecificationExecutor}.
 *
 * @param  The entity type
 * @author Denis Stepanov
 * @since 3.2
 */
public interface ReactiveStreamsJpaSpecificationExecutor {

    /**
     * Returns a single entity matching the given {@link QuerySpecification}.
     *
     * @param spec The query specification
     * @return optional found result
     */
    @NonNull
    Publisher findOne(@Nullable QuerySpecification spec);

    /**
     * Returns a single entity matching the given {@link PredicateSpecification}.
     *
     * @param spec The query specification
     * @return optional found result
     */
    @NonNull
    Publisher findOne(@Nullable PredicateSpecification spec);

    /**
     * Returns all entities matching the given {@link QuerySpecification}.
     *
     * @param spec The query specification
     * @return found results
     */
    @NonNull
    Publisher findAll(@Nullable QuerySpecification spec);

    /**
     * Returns all entities matching the given {@link PredicateSpecification}.
     *
     * @param spec The query specification
     * @return found results
     */
    @NonNull
    Publisher findAll(@Nullable PredicateSpecification spec);

    /**
     * Returns a {@link Page} of entities matching the given {@link QuerySpecification}.
     *
     * @param spec     The query specification
     * @param pageable The pageable object
     * @return a page
     */
    @NonNull
    Publisher> findAll(@Nullable QuerySpecification spec, Pageable pageable);

    /**
     * Returns a {@link Page} of entities matching the given {@link PredicateSpecification}.
     *
     * @param spec     The query specification
     * @param pageable The pageable object
     * @return a page
     */
    @NonNull
    Publisher> findAll(@Nullable PredicateSpecification spec, Pageable pageable);

    /**
     * Returns all entities matching the given {@link QuerySpecification} and {@link Sort}.
     *
     * @param spec The query specification
     * @param sort The sort object
     * @return found results
     */
    @NonNull
    Publisher findAll(@Nullable QuerySpecification spec, Sort sort);

    /**
     * Returns all entities matching the given {@link QuerySpecification} and {@link Sort}.
     *
     * @param spec The query specification
     * @param sort The sort object
     * @return found results
     */
    @NonNull
    Publisher findAll(@Nullable PredicateSpecification spec, Sort sort);

    /**
     * Returns the number of instances that the given {@link QuerySpecification} will return.
     *
     * @param spec The query specification
     * @return the number of instances.
     */
    @NonNull
    Publisher count(@Nullable QuerySpecification spec);

    /**
     * Returns the number of instances that the given {@link QuerySpecification} will return.
     *
     * @param spec The query specification
     * @return the number of instances.
     */
    @NonNull
    Publisher count(@Nullable PredicateSpecification spec);

    /**
     * Returns whether an instance was found for the given {@link QuerySpecification}.
     *
     * @param spec The query specification
     * @return the number of instances.
     * @since 3.8
     */
    @NonNull
    Publisher exists(@Nullable QuerySpecification spec);

    /**
     * Returns whether an instance was found for the given {@link PredicateSpecification}.
     *
     * @param spec The query specification
     * @return the number of instances.
     * @since 3.8
     */
    @NonNull
    Publisher exists(@Nullable PredicateSpecification spec);

    /**
     * Deletes all entities matching the given {@link DeleteSpecification}.
     *
     * @param spec The delete specification
     * @return the number records deleted.
     */
    @NonNull
    Publisher deleteAll(@Nullable DeleteSpecification spec);

    /**
     * Deletes all entities matching the given {@link PredicateSpecification}.
     *
     * @param spec The delete specification
     * @return the number records deleted.
     */
    @NonNull
    Publisher deleteAll(@Nullable PredicateSpecification spec);

    /**
     * Updates all entities matching the given {@link UpdateSpecification}.
     *
     * @param spec The update specification
     * @return the number records updated.
     */
    @NonNull
    Publisher updateAll(@Nullable UpdateSpecification spec);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy