Skip to content

Commit 78fbea4

Browse files
Polishing.
Add since tags to extension methods and issue references to tests. Update antora playbook to consider maintenance branches. Original Pull Request: #4753
1 parent df08576 commit 78fbea4

File tree

4 files changed

+53
-29
lines changed

4 files changed

+53
-29
lines changed

Diff for: spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensions.kt

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 the original author or authors.
2+
* Copyright 2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import kotlin.reflect.KProperty
2323
* Static factory method to create an Update using the provided key
2424
*
2525
* @author Pawel Matysek
26+
* @since 4.4
2627
* @see Update.update
2728
*/
2829
fun <T> update(key: KProperty<T>, value: T?) =
@@ -32,6 +33,7 @@ fun <T> update(key: KProperty<T>, value: T?) =
3233
* Update using the {@literal $set} update modifier
3334
*
3435
* @author Pawel Matysek
36+
* @since 4.4
3537
* @see Update.set
3638
*/
3739
fun <T> Update.set(key: KProperty<T>, value: T?) =
@@ -41,6 +43,7 @@ fun <T> Update.set(key: KProperty<T>, value: T?) =
4143
* Update using the {@literal $setOnInsert} update modifier
4244
*
4345
* @author Pawel Matysek
46+
* @since 4.4
4447
* @see Update.setOnInsert
4548
*/
4649
fun <T> Update.setOnInsert(key: KProperty<T>, value: T?) =
@@ -50,6 +53,7 @@ fun <T> Update.setOnInsert(key: KProperty<T>, value: T?) =
5053
* Update using the {@literal $unset} update modifier
5154
*
5255
* @author Pawel Matysek
56+
* @since 4.4
5357
* @see Update.unset
5458
*/
5559
fun <T> Update.unset(key: KProperty<T>) =
@@ -59,6 +63,7 @@ fun <T> Update.unset(key: KProperty<T>) =
5963
* Update using the {@literal $inc} update modifier
6064
*
6165
* @author Pawel Matysek
66+
* @since 4.4
6267
* @see Update.inc
6368
*/
6469
fun <T> Update.inc(key: KProperty<T>, inc: Number) =
@@ -71,6 +76,7 @@ fun <T> Update.inc(key: KProperty<T>) =
7176
* Update using the {@literal $push} update modifier
7277
*
7378
* @author Pawel Matysek
79+
* @since 4.4
7480
* @see Update.push
7581
*/
7682
fun <T> Update.push(key: KProperty<Collection<T>>, value: T?) =
@@ -79,9 +85,10 @@ fun <T> Update.push(key: KProperty<Collection<T>>, value: T?) =
7985
/**
8086
* Update using {@code $push} modifier. <br/>
8187
* Allows creation of {@code $push} command for single or multiple (using {@code $each}) values as well as using
82-
*
8388
* {@code $position}.
89+
*
8490
* @author Pawel Matysek
91+
* @since 4.4
8592
* @see Update.push
8693
*/
8794
fun <T> Update.push(key: KProperty<T>) =
@@ -92,6 +99,7 @@ fun <T> Update.push(key: KProperty<T>) =
9299
* Allows creation of {@code $push} command for single or multiple (using {@code $each}) values * {@code $position}.
93100
*
94101
* @author Pawel Matysek
102+
* @since 4.4
95103
* @see Update.addToSet
96104
*/
97105
fun <T> Update.addToSet(key: KProperty<T>) =
@@ -101,6 +109,7 @@ fun <T> Update.addToSet(key: KProperty<T>) =
101109
* Update using the {@literal $addToSet} update modifier
102110
*
103111
* @author Pawel Matysek
112+
* @since 4.4
104113
* @see Update.addToSet
105114
*/
106115
fun <T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
@@ -110,6 +119,7 @@ fun <T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
110119
* Update using the {@literal $pop} update modifier
111120
*
112121
* @author Pawel Matysek
122+
* @since 4.4
113123
* @see Update.pop
114124
*/
115125
fun <T> Update.pop(key: KProperty<T>, pos: Position) =
@@ -119,6 +129,7 @@ fun <T> Update.pop(key: KProperty<T>, pos: Position) =
119129
* Update using the {@literal $pull} update modifier
120130
*
121131
* @author Pawel Matysek
132+
* @since 4.4
122133
* @see Update.pull
123134
*/
124135
fun <T> Update.pull(key: KProperty<T>, value: Any) =
@@ -128,6 +139,7 @@ fun <T> Update.pull(key: KProperty<T>, value: Any) =
128139
* Update using the {@literal $pullAll} update modifier
129140
*
130141
* @author Pawel Matysek
142+
* @since 4.4
131143
* @see Update.pullAll
132144
*/
133145
fun <T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
@@ -137,6 +149,7 @@ fun <T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
137149
* Update given key to current date using {@literal $currentDate} modifier.
138150
*
139151
* @author Pawel Matysek
152+
* @since 4.4
140153
* @see Update.currentDate
141154
*/
142155
fun <T> Update.currentDate(key: KProperty<T>) =
@@ -146,6 +159,7 @@ fun <T> Update.currentDate(key: KProperty<T>) =
146159
* Update given key to current date using {@literal $currentDate : &#123; $type : "timestamp" &#125;} modifier.
147160
*
148161
* @author Pawel Matysek
162+
* @since 4.4
149163
* @see Update.currentTimestamp
150164
*/
151165
fun <T> Update.currentTimestamp(key: KProperty<T>) =
@@ -155,6 +169,7 @@ fun <T> Update.currentTimestamp(key: KProperty<T>) =
155169
* Multiply the value of given key by the given number.
156170
*
157171
* @author Pawel Matysek
172+
* @since 4.4
158173
* @see Update.multiply
159174
*/
160175
fun <T> Update.multiply(key: KProperty<T>, multiplier: Number) =
@@ -164,6 +179,7 @@ fun <T> Update.multiply(key: KProperty<T>, multiplier: Number) =
164179
* Update given key to the {@code value} if the {@code value} is greater than the current value of the field.
165180
*
166181
* @author Pawel Matysek
182+
* @since 4.4
167183
* @see Update.max
168184
*/
169185
fun <T : Any> Update.max(key: KProperty<T>, value: T) =
@@ -173,6 +189,7 @@ fun <T : Any> Update.max(key: KProperty<T>, value: T) =
173189
* Update given key to the {@code value} if the {@code value} is less than the current value of the field.
174190
*
175191
* @author Pawel Matysek
192+
* @since 4.4
176193
* @see Update.min
177194
*/
178195
fun <T : Any> Update.min(key: KProperty<T>, value: T) =
@@ -182,6 +199,7 @@ fun <T : Any> Update.min(key: KProperty<T>, value: T) =
182199
* The operator supports bitwise {@code and}, bitwise {@code or}, and bitwise {@code xor} operations.
183200
*
184201
* @author Pawel Matysek
202+
* @since 4.4
185203
* @see Update.bitwise
186204
*/
187205
fun <T> Update.bitwise(key: KProperty<T>) =
@@ -192,6 +210,7 @@ fun <T> Update.bitwise(key: KProperty<T>) =
192210
* driver without further type or field mapping.
193211
*
194212
* @author Pawel Matysek
213+
* @since 4.4
195214
* @see Update.filterArray
196215
*/
197216
fun <T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
@@ -201,6 +220,7 @@ fun <T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
201220
* Determine if a given {@code key} will be touched on execution.
202221
*
203222
* @author Pawel Matysek
223+
* @since 4.4
204224
* @see Update.modifies
205225
*/
206226
fun <T> Update.modifies(key: KProperty<T>) =

Diff for: spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core/query/TypedUpdateExtensionsTests.kt

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 the original author or authors.
2+
* Copyright 2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import java.time.Instant
2727
*/
2828
class TypedUpdateExtensionsTests {
2929

30-
@Test
30+
@Test // GH-3028
3131
fun `update() should equal expected Update`() {
3232

3333
val typed = update(Book::title, "Moby-Dick")
@@ -36,7 +36,7 @@ class TypedUpdateExtensionsTests {
3636
assertThat(typed).isEqualTo(expected)
3737
}
3838

39-
@Test
39+
@Test // GH-3028
4040
fun `set() should equal expected Update`() {
4141

4242
val typed = Update().set(Book::title, "Moby-Dick")
@@ -45,7 +45,7 @@ class TypedUpdateExtensionsTests {
4545
assertThat(typed).isEqualTo(expected)
4646
}
4747

48-
@Test
48+
@Test // GH-3028
4949
fun `setOnInsert() should equal expected Update`() {
5050

5151
val typed = Update().setOnInsert(Book::title, "Moby-Dick")
@@ -54,7 +54,7 @@ class TypedUpdateExtensionsTests {
5454
assertThat(typed).isEqualTo(expected)
5555
}
5656

57-
@Test
57+
@Test // GH-3028
5858
fun `unset() should equal expected Update`() {
5959

6060
val typed = Update().unset(Book::title)
@@ -63,7 +63,7 @@ class TypedUpdateExtensionsTests {
6363
assertThat(typed).isEqualTo(expected)
6464
}
6565

66-
@Test
66+
@Test // GH-3028
6767
fun `inc(key, inc) should equal expected Update`() {
6868

6969
val typed = Update().inc(Book::price, 5)
@@ -72,7 +72,7 @@ class TypedUpdateExtensionsTests {
7272
assertThat(typed).isEqualTo(expected)
7373
}
7474

75-
@Test
75+
@Test // GH-3028
7676
fun `inc(key) should equal expected Update`() {
7777

7878
val typed = Update().inc(Book::price)
@@ -81,7 +81,7 @@ class TypedUpdateExtensionsTests {
8181
assertThat(typed).isEqualTo(expected)
8282
}
8383

84-
@Test
84+
@Test // GH-3028
8585
fun `push(key, value) should equal expected Update`() {
8686

8787
val typed = Update().push(Book::categories, "someCategory")
@@ -90,7 +90,7 @@ class TypedUpdateExtensionsTests {
9090
assertThat(typed).isEqualTo(expected)
9191
}
9292

93-
@Test
93+
@Test // GH-3028
9494
fun `push(key) should equal expected Update`() {
9595

9696
val typed = Update().push(Book::categories)
@@ -99,7 +99,7 @@ class TypedUpdateExtensionsTests {
9999
assertThat(typed).isEqualTo(expected)
100100
}
101101

102-
@Test
102+
@Test // GH-3028
103103
fun `addToSet(key) should equal expected Update`() {
104104

105105
val typed = Update().addToSet(Book::categories).each("category", "category2")
@@ -108,7 +108,7 @@ class TypedUpdateExtensionsTests {
108108
assertThat(typed).isEqualTo(expected)
109109
}
110110

111-
@Test
111+
@Test // GH-3028
112112
fun `addToSet(key, value) should equal expected Update`() {
113113

114114
val typed = Update().addToSet(Book::categories, "someCategory")
@@ -117,7 +117,7 @@ class TypedUpdateExtensionsTests {
117117
assertThat(typed).isEqualTo(expected)
118118
}
119119

120-
@Test
120+
@Test // GH-3028
121121
fun `pop() should equal expected Update`() {
122122

123123
val typed = Update().pop(Book::categories, Update.Position.FIRST)
@@ -126,7 +126,7 @@ class TypedUpdateExtensionsTests {
126126
assertThat(typed).isEqualTo(expected)
127127
}
128128

129-
@Test
129+
@Test // GH-3028
130130
fun `pull() should equal expected Update`() {
131131

132132
val typed = Update().pull(Book::categories, "someCategory")
@@ -135,7 +135,7 @@ class TypedUpdateExtensionsTests {
135135
assertThat(typed).isEqualTo(expected)
136136
}
137137

138-
@Test
138+
@Test // GH-3028
139139
fun `pullAll() should equal expected Update`() {
140140

141141
val typed = Update().pullAll(Book::categories, arrayOf("someCategory", "someCategory2"))
@@ -144,7 +144,7 @@ class TypedUpdateExtensionsTests {
144144
assertThat(typed).isEqualTo(expected)
145145
}
146146

147-
@Test
147+
@Test // GH-3028
148148
fun `currentDate() should equal expected Update`() {
149149

150150
val typed = Update().currentDate(Book::releaseDate)
@@ -153,7 +153,7 @@ class TypedUpdateExtensionsTests {
153153
assertThat(typed).isEqualTo(expected)
154154
}
155155

156-
@Test
156+
@Test // GH-3028
157157
fun `currentTimestamp() should equal expected Update`() {
158158

159159
val typed = Update().currentTimestamp(Book::releaseDate)
@@ -162,7 +162,7 @@ class TypedUpdateExtensionsTests {
162162
assertThat(typed).isEqualTo(expected)
163163
}
164164

165-
@Test
165+
@Test // GH-3028
166166
fun `multiply() should equal expected Update`() {
167167

168168
val typed = Update().multiply(Book::price, 2)
@@ -171,7 +171,7 @@ class TypedUpdateExtensionsTests {
171171
assertThat(typed).isEqualTo(expected)
172172
}
173173

174-
@Test
174+
@Test // GH-3028
175175
fun `max() should equal expected Update`() {
176176

177177
val typed = Update().max(Book::price, 200)
@@ -180,7 +180,7 @@ class TypedUpdateExtensionsTests {
180180
assertThat(typed).isEqualTo(expected)
181181
}
182182

183-
@Test
183+
@Test // GH-3028
184184
fun `min() should equal expected Update`() {
185185

186186
val typed = Update().min(Book::price, 100)
@@ -189,7 +189,7 @@ class TypedUpdateExtensionsTests {
189189
assertThat(typed).isEqualTo(expected)
190190
}
191191

192-
@Test
192+
@Test // GH-3028
193193
fun `bitwise() should equal expected Update`() {
194194

195195
val typed = Update().bitwise(Book::price).and(2)
@@ -198,7 +198,7 @@ class TypedUpdateExtensionsTests {
198198
assertThat(typed).isEqualTo(expected)
199199
}
200200

201-
@Test
201+
@Test // GH-3028
202202
fun `filterArray() should equal expected Update`() {
203203

204204
val typed = Update().filterArray(Book::categories, "someCategory")
@@ -207,7 +207,7 @@ class TypedUpdateExtensionsTests {
207207
assertThat(typed).isEqualTo(expected)
208208
}
209209

210-
@Test
210+
@Test // GH-3028
211211
fun `typed modifies() should equal expected modifies()`() {
212212

213213
val typed = update(Book::title, "Moby-Dick")
@@ -216,7 +216,7 @@ class TypedUpdateExtensionsTests {
216216
assertThat(typed.modifies(Book::price)).isEqualTo(typed.modifies("price"))
217217
}
218218

219-
@Test
219+
@Test // GH-3028
220220
fun `One level nested should equal expected Update`() {
221221

222222
val typed = update(Book::author / Author::name, "Herman Melville")
@@ -225,7 +225,7 @@ class TypedUpdateExtensionsTests {
225225
assertThat(typed).isEqualTo(expected)
226226
}
227227

228-
@Test
228+
@Test // GH-3028
229229
fun `Two levels nested should equal expected Update`() {
230230

231231
data class Entity(val book: Book)

Diff for: src/main/antora/antora-playbook.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ content:
1717
- url: https://github.com/spring-projects/spring-data-commons
1818
# Refname matching:
1919
# https://docs.antora.org/antora/latest/playbook/content-refname-matching/
20-
branches: [ main, 3.2.x ]
20+
branches: [ main, 3.3.x, 3.2.x]
2121
start_path: src/main/antora
2222
asciidoc:
2323
attributes:

0 commit comments

Comments
 (0)