|
| 1 | +/* |
| 2 | + * Copyright 2019 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.querydsl; |
| 17 | + |
| 18 | +import reactor.core.publisher.Flux; |
| 19 | +import reactor.core.publisher.Mono; |
| 20 | + |
| 21 | +import org.springframework.data.domain.Sort; |
| 22 | + |
| 23 | +import com.querydsl.core.types.OrderSpecifier; |
| 24 | +import com.querydsl.core.types.Predicate; |
| 25 | + |
| 26 | +/** |
| 27 | + * Interface to issue queries using Querydsl {@link Predicate} instances. |
| 28 | + * |
| 29 | + * @author Mark Paluch |
| 30 | + * @since 2.2 |
| 31 | + */ |
| 32 | +public interface ReactiveQuerydslPredicateExecutor<T> { |
| 33 | + |
| 34 | + /** |
| 35 | + * Returns a single entity matching the given {@link Predicate} or {@link Mono#empty()} if none was found. |
| 36 | + * |
| 37 | + * @param predicate must not be {@literal null}. |
| 38 | + * @return a single entity matching the given {@link Predicate} or {@link Mono#empty()} if none was found. |
| 39 | + * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the predicate yields more than one |
| 40 | + * result. |
| 41 | + */ |
| 42 | + Mono<T> findOne(Predicate predicate); |
| 43 | + |
| 44 | + /** |
| 45 | + * Returns all entities matching the given {@link Predicate}. In case no match could be found, {@link Flux} emits no |
| 46 | + * items. |
| 47 | + * |
| 48 | + * @param predicate must not be {@literal null}. |
| 49 | + * @return all entities matching the given {@link Predicate}. |
| 50 | + */ |
| 51 | + Flux<T> findAll(Predicate predicate); |
| 52 | + |
| 53 | + /** |
| 54 | + * Returns all entities matching the given {@link Predicate} applying the given {@link Sort}. In case no match could |
| 55 | + * be found, {@link Flux} emits no items. |
| 56 | + * |
| 57 | + * @param predicate must not be {@literal null}. |
| 58 | + * @param sort the {@link Sort} specification to sort the results by, may be {@link Sort#empty()}, must not be |
| 59 | + * {@literal null}. |
| 60 | + * @return all entities matching the given {@link Predicate}. |
| 61 | + */ |
| 62 | + Flux<T> findAll(Predicate predicate, Sort sort); |
| 63 | + |
| 64 | + /** |
| 65 | + * Returns all entities matching the given {@link Predicate} applying the given {@link OrderSpecifier}s. In case no |
| 66 | + * match could be found, {@link Flux} emits no items. |
| 67 | + * |
| 68 | + * @param predicate must not be {@literal null}. |
| 69 | + * @param orders the {@link OrderSpecifier}s to sort the results by. |
| 70 | + * @return all entities matching the given {@link Predicate} applying the given {@link OrderSpecifier}s. |
| 71 | + */ |
| 72 | + Flux<T> findAll(Predicate predicate, OrderSpecifier<?>... orders); |
| 73 | + |
| 74 | + /** |
| 75 | + * Returns all entities ordered by the given {@link OrderSpecifier}s. |
| 76 | + * |
| 77 | + * @param orders the {@link OrderSpecifier}s to sort the results by. |
| 78 | + * @return all entities ordered by the given {@link OrderSpecifier}s. |
| 79 | + */ |
| 80 | + Flux<T> findAll(OrderSpecifier<?>... orders); |
| 81 | + |
| 82 | + /** |
| 83 | + * Returns the number of instances matching the given {@link Predicate}. |
| 84 | + * |
| 85 | + * @param predicate the {@link Predicate} to count instances for, must not be {@literal null}. |
| 86 | + * @return the number of instances matching the {@link Predicate}. |
| 87 | + */ |
| 88 | + Mono<Long> count(Predicate predicate); |
| 89 | + |
| 90 | + /** |
| 91 | + * Checks whether the data store contains elements that match the given {@link Predicate}. |
| 92 | + * |
| 93 | + * @param predicate the {@link Predicate} to use for the existence check, must not be {@literal null}. |
| 94 | + * @return {@literal true} if the data store contains elements that match the given {@link Predicate}. |
| 95 | + */ |
| 96 | + Mono<Boolean> exists(Predicate predicate); |
| 97 | +} |
0 commit comments