Skip to content

Commit f20b571

Browse files
mp911dechristophstrobl
authored andcommitted
DATACMNS-995 - Create ReactiveQueryByExampleExecutor allowing reactive query by example.
Provide a mix-in interface to be used in store modules providing reactive Query by Example query execution.
1 parent d33387a commit f20b571

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright 2017 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.repository.query;
17+
18+
import reactor.core.publisher.Flux;
19+
import reactor.core.publisher.Mono;
20+
21+
import org.springframework.data.domain.Example;
22+
import org.springframework.data.domain.Sort;
23+
24+
/**
25+
* Interface to allow execution of Query by Example {@link Example} instances using a reactive infrastructure.
26+
*
27+
* @param <T>
28+
* @author Mark Paluch
29+
* @since 2.0
30+
*/
31+
public interface ReactiveQueryByExampleExecutor<T> {
32+
33+
/**
34+
* Returns a single entity matching the given {@link Example} or {@literal null} if none was found.
35+
*
36+
* @param example can be {@literal null}.
37+
* @return a single entity matching the given {@link Example} or {@literal null} if none was found.
38+
*/
39+
<S extends T> Mono<S> findOne(Example<S> example);
40+
41+
/**
42+
* Returns all entities matching the given {@link Example}. In case no match could be found an empty {@link Iterable}
43+
* is returned.
44+
*
45+
* @param example can be {@literal null}.
46+
* @return all entities matching the given {@link Example}.
47+
*/
48+
<S extends T> Flux<S> findAll(Example<S> example);
49+
50+
/**
51+
* Returns all entities matching the given {@link Example} applying the given {@link Sort}. In case no match could be
52+
* found an empty {@link Iterable} is returned.
53+
*
54+
* @param example can be {@literal null}.
55+
* @param sort the {@link Sort} specification to sort the results by, must not be {@literal null}.
56+
* @return all entities matching the given {@link Example}.
57+
*/
58+
<S extends T> Flux<S> findAll(Example<S> example, Sort sort);
59+
60+
/**
61+
* Returns the number of instances matching the given {@link Example}.
62+
*
63+
* @param example the {@link Example} to count instances for, can be {@literal null}.
64+
* @return the number of instances matching the {@link Example}.
65+
*/
66+
<S extends T> Mono<Long> count(Example<S> example);
67+
68+
/**
69+
* Checks whether the data store contains elements that match the given {@link Example}.
70+
*
71+
* @param example the {@link Example} to use for the existence check, can be {@literal null}.
72+
* @return {@literal true} if the data store contains elements that match the given {@link Example}.
73+
*/
74+
<S extends T> Mono<Boolean> exists(Example<S> example);
75+
}

0 commit comments

Comments
 (0)