Skip to content

Commit 6b98cb8

Browse files
committed
enforce type-safety in TypedPropertyPath<?, ?>
Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
1 parent cf92b6c commit 6b98cb8

10 files changed

Lines changed: 30 additions & 21 deletions

src/main/java/org/springframework/data/couchbase/core/ExecutableFindByIdOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ interface FindByIdWithProjection<T> extends FindByIdInScope<T>, WithProjectionId
133133
* @since 6.1
134134
*/
135135
@SuppressWarnings("unchecked")
136-
default FindByIdInScope<T> project(TypedPropertyPath<?, ?>... fields) {
136+
default FindByIdInScope<T> project(TypedPropertyPath<T, ?>... fields) {
137137
return project(Arrays.stream(fields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
138138
}
139139
}

src/main/java/org/springframework/data/couchbase/core/ExecutableFindByQueryOperation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ interface FindByQueryWithProjecting<T> extends FindByQueryWithProjection<T> {
282282
* @since 6.1
283283
*/
284284
@SuppressWarnings("unchecked")
285-
default FindByQueryWithProjection<T> project(TypedPropertyPath<?, ?>... fields) {
285+
default FindByQueryWithProjection<T> project(TypedPropertyPath<T, ?>... fields) {
286286
return project(Arrays.stream(fields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
287287
}
288288
}
@@ -311,7 +311,7 @@ interface FindByQueryWithDistinct<T> extends FindByQueryWithProjecting<T>, WithD
311311
* @since 6.1
312312
*/
313313
@SuppressWarnings("unchecked")
314-
default FindByQueryWithProjection<T> distinct(TypedPropertyPath<?, ?>... distinctFields) {
314+
default FindByQueryWithProjection<T> distinct(TypedPropertyPath<T, ?>... distinctFields) {
315315
return distinct(Arrays.stream(distinctFields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
316316
}
317317
}

src/main/java/org/springframework/data/couchbase/core/ExecutableMutateInByIdOperation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ interface MutateInByIdWithPaths<T> extends TerminatingMutateInById<T>, WithMutat
107107
* @since 6.1
108108
*/
109109
@SuppressWarnings("unchecked")
110-
default MutateInByIdWithPaths<T> withRemovePaths(TypedPropertyPath<?, ?>... removePaths) {
110+
default MutateInByIdWithPaths<T> withRemovePaths(TypedPropertyPath<T, ?>... removePaths) {
111111
return withRemovePaths(Arrays.stream(removePaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
112112
}
113113

@@ -116,7 +116,7 @@ default MutateInByIdWithPaths<T> withRemovePaths(TypedPropertyPath<?, ?>... remo
116116
* @since 6.1
117117
*/
118118
@SuppressWarnings("unchecked")
119-
default MutateInByIdWithPaths<T> withInsertPaths(TypedPropertyPath<?, ?>... insertPaths) {
119+
default MutateInByIdWithPaths<T> withInsertPaths(TypedPropertyPath<T, ?>... insertPaths) {
120120
return withInsertPaths(Arrays.stream(insertPaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
121121
}
122122

@@ -125,7 +125,7 @@ default MutateInByIdWithPaths<T> withInsertPaths(TypedPropertyPath<?, ?>... inse
125125
* @since 6.1
126126
*/
127127
@SuppressWarnings("unchecked")
128-
default MutateInByIdWithPaths<T> withUpsertPaths(TypedPropertyPath<?, ?>... upsertPaths) {
128+
default MutateInByIdWithPaths<T> withUpsertPaths(TypedPropertyPath<T, ?>... upsertPaths) {
129129
return withUpsertPaths(Arrays.stream(upsertPaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
130130
}
131131

@@ -134,7 +134,7 @@ default MutateInByIdWithPaths<T> withUpsertPaths(TypedPropertyPath<?, ?>... upse
134134
* @since 6.1
135135
*/
136136
@SuppressWarnings("unchecked")
137-
default MutateInByIdWithPaths<T> withReplacePaths(TypedPropertyPath<?, ?>... replacePaths) {
137+
default MutateInByIdWithPaths<T> withReplacePaths(TypedPropertyPath<T, ?>... replacePaths) {
138138
return withReplacePaths(Arrays.stream(replacePaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
139139
}
140140
}

src/main/java/org/springframework/data/couchbase/core/ReactiveFindByIdOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ interface FindByIdWithProjection<T> extends FindByIdInScope<T>, WithProjectionId
136136
* @since 6.1
137137
*/
138138
@SuppressWarnings("unchecked")
139-
default FindByIdInCollection<T> project(TypedPropertyPath<?, ?>... fields) {
139+
default FindByIdInCollection<T> project(TypedPropertyPath<T, ?>... fields) {
140140
return project(Arrays.stream(fields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
141141
}
142142

src/main/java/org/springframework/data/couchbase/core/ReactiveFindByQueryOperation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ interface FindByQueryWithProjecting<T> extends FindByQueryWithProjection<T> {
228228
* @param fields the property paths to project.
229229
* @since 6.1
230230
*/
231-
default FindByQueryWithProjection<T> project(TypedPropertyPath<?, ?>... fields) {
231+
@SuppressWarnings("unchecked")
232+
default FindByQueryWithProjection<T> project(TypedPropertyPath<T, ?>... fields) {
232233
return project(Arrays.stream(fields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
233234
}
234235
}
@@ -255,7 +256,8 @@ interface FindByQueryWithDistinct<T> extends FindByQueryWithProjecting<T>, WithD
255256
* @param distinctFields the property paths for distinct fields.
256257
* @since 6.1
257258
*/
258-
default FindByQueryWithProjection<T> distinct(TypedPropertyPath<?, ?>... distinctFields) {
259+
@SuppressWarnings("unchecked")
260+
default FindByQueryWithProjection<T> distinct(TypedPropertyPath<T, ?>... distinctFields) {
259261
return distinct(Arrays.stream(distinctFields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
260262
}
261263
}

src/main/java/org/springframework/data/couchbase/core/ReactiveMutateInByIdOperation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,31 +106,31 @@ interface MutateInByIdWithPaths<T> extends TerminatingMutateInById<T>, WithMutat
106106
* Type-safe variant of {@link #withRemovePaths(String...)} using property paths.
107107
* @since 6.1
108108
*/
109-
default MutateInByIdWithPaths<T> withRemovePaths(TypedPropertyPath<?, ?>... removePaths) {
109+
default MutateInByIdWithPaths<T> withRemovePaths(TypedPropertyPath<T, ?>... removePaths) {
110110
return withRemovePaths(Arrays.stream(removePaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
111111
}
112112

113113
/**
114114
* Type-safe variant of {@link #withInsertPaths(String...)} using property paths.
115115
* @since 6.1
116116
*/
117-
default MutateInByIdWithPaths<T> withInsertPaths(TypedPropertyPath<?, ?>... insertPaths) {
117+
default MutateInByIdWithPaths<T> withInsertPaths(TypedPropertyPath<T, ?>... insertPaths) {
118118
return withInsertPaths(Arrays.stream(insertPaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
119119
}
120120

121121
/**
122122
* Type-safe variant of {@link #withUpsertPaths(String...)} using property paths.
123123
* @since 6.1
124124
*/
125-
default MutateInByIdWithPaths<T> withUpsertPaths(TypedPropertyPath<?, ?>... upsertPaths) {
125+
default MutateInByIdWithPaths<T> withUpsertPaths(TypedPropertyPath<T, ?>... upsertPaths) {
126126
return withUpsertPaths(Arrays.stream(upsertPaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
127127
}
128128

129129
/**
130130
* Type-safe variant of {@link #withReplacePaths(String...)} using property paths.
131131
* @since 6.1
132132
*/
133-
default MutateInByIdWithPaths<T> withReplacePaths(TypedPropertyPath<?, ?>... replacePaths) {
133+
default MutateInByIdWithPaths<T> withReplacePaths(TypedPropertyPath<T, ?>... replacePaths) {
134134
return withReplacePaths(Arrays.stream(replacePaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
135135
}
136136
}

src/main/java/org/springframework/data/couchbase/core/support/WithDistinct.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public interface WithDistinct<T> {
4040
* @param distinctFields the property paths to use as distinct fields.
4141
* @since 6.1
4242
*/
43-
default Object distinct(TypedPropertyPath<?, ?>... distinctFields) {
43+
@SuppressWarnings("unchecked")
44+
default Object distinct(TypedPropertyPath<T, ?>... distinctFields) {
4445
return distinct(Arrays.stream(distinctFields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
4546
}
4647
}

src/main/java/org/springframework/data/couchbase/core/support/WithMutateInPaths.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public interface WithMutateInPaths<T> {
4040
*
4141
* @since 6.1
4242
*/
43-
default Object withRemovePaths(TypedPropertyPath<?, ?>... removePaths) {
43+
@SuppressWarnings("unchecked")
44+
default Object withRemovePaths(TypedPropertyPath<T, ?>... removePaths) {
4445
return withRemovePaths(Arrays.stream(removePaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
4546
}
4647

@@ -49,7 +50,8 @@ default Object withRemovePaths(TypedPropertyPath<?, ?>... removePaths) {
4950
*
5051
* @since 6.1
5152
*/
52-
default Object withInsertPaths(TypedPropertyPath<?, ?>... insertPaths) {
53+
@SuppressWarnings("unchecked")
54+
default Object withInsertPaths(TypedPropertyPath<T, ?>... insertPaths) {
5355
return withInsertPaths(Arrays.stream(insertPaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
5456
}
5557

@@ -58,7 +60,8 @@ default Object withInsertPaths(TypedPropertyPath<?, ?>... insertPaths) {
5860
*
5961
* @since 6.1
6062
*/
61-
default Object withReplacePaths(TypedPropertyPath<?, ?>... replacePaths) {
63+
@SuppressWarnings("unchecked")
64+
default Object withReplacePaths(TypedPropertyPath<T, ?>... replacePaths) {
6265
return withReplacePaths(Arrays.stream(replacePaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
6366
}
6467

@@ -67,7 +70,8 @@ default Object withReplacePaths(TypedPropertyPath<?, ?>... replacePaths) {
6770
*
6871
* @since 6.1
6972
*/
70-
default Object withUpsertPaths(TypedPropertyPath<?, ?>... upsertPaths) {
73+
@SuppressWarnings("unchecked")
74+
default Object withUpsertPaths(TypedPropertyPath<T, ?>... upsertPaths) {
7175
return withUpsertPaths(Arrays.stream(upsertPaths).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
7276
}
7377
}

src/main/java/org/springframework/data/couchbase/core/support/WithProjecting.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public interface WithProjecting<R> {
3535
* @param fields the property paths to project.
3636
* @since 6.1
3737
*/
38-
default Object project(TypedPropertyPath<?, ?>... fields) {
38+
@SuppressWarnings("unchecked")
39+
default Object project(TypedPropertyPath<R, ?>... fields) {
3940
return project(Arrays.stream(fields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
4041
}
4142
}

src/main/java/org/springframework/data/couchbase/core/support/WithProjectionId.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public interface WithProjectionId<R> {
3535
* @param fields the property paths to project.
3636
* @since 6.1
3737
*/
38-
default Object project(TypedPropertyPath<?, ?>... fields) {
38+
@SuppressWarnings("unchecked")
39+
default Object project(TypedPropertyPath<R, ?>... fields) {
3940
return project(Arrays.stream(fields).map(TypedPropertyPath::toDotPath).toArray(String[]::new));
4041
}
4142
}

0 commit comments

Comments
 (0)