22
22
23
23
import org .bson .BsonTimestamp ;
24
24
import org .bson .BsonValue ;
25
- import org .bson .Document ;
26
25
import org .springframework .data .mongodb .core .ChangeStreamOptions .ChangeStreamOptionsBuilder ;
27
- import org .springframework .data .mongodb .core .ReactiveFindOperation .ReactiveFind ;
28
26
import org .springframework .data .mongodb .core .aggregation .Aggregation ;
29
27
import org .springframework .data .mongodb .core .query .CriteriaDefinition ;
30
28
54
52
*/
55
53
public interface ReactiveChangeStreamOperation {
56
54
57
- /**
58
- * Start creating a change stream operation.watching all collections within the database. <br />
59
- * Consider limiting events be defining a {@link ChangeStreamWithCollection#watchCollection(String) collection} and/or
60
- * {@link ChangeStreamWithFilter#filter(CriteriaDefinition) filter}.
61
- *
62
- * @return new instance of {@link ReactiveFind}. Never {@literal null}.
63
- */
64
- ReactiveChangeStream <Document > changeStream ();
65
-
66
55
/**
67
56
* Start creating a change stream operation for the given {@literal domainType} watching all collections within the
68
57
* database. <br />
69
58
* Consider limiting events be defining a {@link ChangeStreamWithCollection#watchCollection(String) collection} and/or
70
- * {@link ChangeStreamWithFilter #filter(CriteriaDefinition) filter}.
59
+ * {@link ChangeStreamWithFilterAndProjection #filter(CriteriaDefinition) filter}.
71
60
*
72
- * @param domainType must not be {@literal null}.
61
+ * @param domainType must not be {@literal null}. Use {@link org.bson.Document} to obtain raw elements.
73
62
* @return new instance of {@link ReactiveChangeStream}. Never {@literal null}.
74
63
* @throws IllegalArgumentException if domainType is {@literal null}.
75
64
*/
@@ -102,48 +91,42 @@ interface ChangeStreamWithCollection<T> {
102
91
* @return new instance of {@link ChangeStreamWithCollection}.
103
92
* @throws IllegalArgumentException if collection is {@literal null}.
104
93
*/
105
- ChangeStreamWithProjection <T > watchCollection (String collection );
106
- }
107
-
108
- /**
109
- * Result type override (optional).
110
- */
111
- interface ChangeStreamWithProjection <T > extends ChangeStreamWithFilter <T > {
112
-
113
- /**
114
- * Define the target type fields should be mapped to.
115
- *
116
- * @param resultType must not be {@literal null}.
117
- * @param <R> result type.
118
- * @return new instance of {@link ChangeStreamWithProjection}.
119
- * @throws IllegalArgumentException if resultType is {@literal null}.
120
- */
121
- <R > ChangeStreamWithFilter <R > as (Class <R > resultType );
94
+ ChangeStreamWithFilterAndProjection <T > watchCollection (String collection );
122
95
}
123
96
124
97
/**
125
98
* Provide a filter for limiting results (optional).
126
99
*/
127
- interface ChangeStreamWithFilter <T > extends ResumingChangeStream <T >, TerminatingChangeStream <T > {
100
+ interface ChangeStreamWithFilterAndProjection <T > extends ResumingChangeStream <T >, TerminatingChangeStream <T > {
128
101
129
102
/**
130
103
* Use an {@link Aggregation} to filter matching events.
131
104
*
132
105
* @param by must not be {@literal null}.
133
- * @return new instance of {@link ChangeStreamWithProjection }.
106
+ * @return new instance of {@link ChangeStreamWithFilterAndProjection }.
134
107
* @throws IllegalArgumentException if the given {@link Aggregation} is {@literal null}.
135
108
*/
136
- ChangeStreamWithProjection <T > filter (Aggregation by );
109
+ ChangeStreamWithFilterAndProjection <T > filter (Aggregation by );
137
110
138
111
/**
139
112
* Use a {@link CriteriaDefinition critera} to filter matching events via an
140
113
* {@link org.springframework.data.mongodb.core.aggregation.MatchOperation}.
141
114
*
142
115
* @param by must not be {@literal null}.
143
- * @return new instance of {@link ChangeStreamWithProjection }.
116
+ * @return new instance of {@link ChangeStreamWithFilterAndProjection }.
144
117
* @throws IllegalArgumentException if the given {@link CriteriaDefinition} is {@literal null}.
145
118
*/
146
- ChangeStreamWithProjection <T > filter (CriteriaDefinition by );
119
+ ChangeStreamWithFilterAndProjection <T > filter (CriteriaDefinition by );
120
+
121
+ /**
122
+ * Define the target type fields should be mapped to.
123
+ *
124
+ * @param resultType must not be {@literal null}.
125
+ * @param <R> result type.
126
+ * @return new instance of {@link ChangeStreamWithFilterAndProjection}.
127
+ * @throws IllegalArgumentException if resultType is {@literal null}.
128
+ */
129
+ <R > ChangeStreamWithFilterAndProjection <R > as (Class <R > resultType );
147
130
}
148
131
149
132
/**
@@ -154,34 +137,34 @@ interface ResumingChangeStream<T> extends TerminatingChangeStream<T> {
154
137
/**
155
138
* Resume the change stream at a given point.
156
139
*
157
- * @param beacon an {@link Instant} or {@link BsonTimestamp}
140
+ * @param token an {@link Instant} or {@link BsonTimestamp}
158
141
* @return new instance of {@link TerminatingChangeStream}.
159
142
* @see ChangeStreamOptionsBuilder#resumeAt(Instant)
160
143
* @see ChangeStreamOptionsBuilder#resumeAt(BsonTimestamp)
161
144
* @throws IllegalArgumentException if the given beacon is neither {@link Instant} nor {@link BsonTimestamp}.
162
145
*/
163
- TerminatingChangeStream <T > resumeAt (Object beacon );
146
+ TerminatingChangeStream <T > resumeAt (Object token );
164
147
165
148
/**
166
149
* Resume the change stream after a given point.
167
150
*
168
- * @param beacon an {@link Instant} or {@link BsonTimestamp}
151
+ * @param token an {@link Instant} or {@link BsonTimestamp}
169
152
* @return new instance of {@link TerminatingChangeStream}.
170
153
* @see ChangeStreamOptionsBuilder#resumeAfter(BsonValue)
171
154
* @see ChangeStreamOptionsBuilder#resumeToken(BsonValue)
172
155
* @throws IllegalArgumentException if the given beacon not a {@link BsonValue}.
173
156
*/
174
- TerminatingChangeStream <T > resumeAfter (Object beacon );
157
+ TerminatingChangeStream <T > resumeAfter (Object token );
175
158
176
159
/**
177
160
* Start the change stream after a given point.
178
161
*
179
- * @param beacon an {@link Instant} or {@link BsonTimestamp}
162
+ * @param token an {@link Instant} or {@link BsonTimestamp}
180
163
* @return new instance of {@link TerminatingChangeStream}.
181
164
* @see ChangeStreamOptionsBuilder#startAfter(BsonValue) (BsonValue)
182
165
* @throws IllegalArgumentException if the given beacon not a {@link BsonValue}.
183
166
*/
184
- TerminatingChangeStream <T > startAfter (Object beacon );
167
+ TerminatingChangeStream <T > startAfter (Object token );
185
168
}
186
169
187
170
/**
@@ -204,5 +187,5 @@ interface ChangeStreamWithOptions<T> {
204
187
* {@link ReactiveChangeStream} provides methods for constructing change stream operations in a fluent way.
205
188
*/
206
189
interface ReactiveChangeStream <T > extends ChangeStreamWithOptions <T >, ChangeStreamWithCollection <T >,
207
- TerminatingChangeStream <T >, ResumingChangeStream <T >, ChangeStreamWithFilter <T > {}
190
+ TerminatingChangeStream <T >, ResumingChangeStream <T >, ChangeStreamWithFilterAndProjection <T > {}
208
191
}
0 commit comments