15
15
*/
16
16
package org .springframework .data .ldap .repository .query ;
17
17
18
+ import org .jspecify .annotations .Nullable ;
19
+
18
20
import org .springframework .core .convert .converter .Converter ;
19
21
import org .springframework .dao .EmptyResultDataAccessException ;
20
22
import org .springframework .data .convert .DtoInstantiatingConverter ;
39
41
@ FunctionalInterface
40
42
interface LdapQueryExecution {
41
43
44
+ @ Nullable
42
45
Object execute (LdapQuery query );
43
46
44
47
/**
@@ -57,13 +60,14 @@ final class FindOneExecution implements LdapQueryExecution {
57
60
}
58
61
59
62
@ Override
60
- public Object execute (LdapQuery query ) {
63
+ public @ Nullable Object execute (LdapQuery query ) {
61
64
try {
62
65
return operations .findOne (query , entityType );
63
66
} catch (EmptyResultDataAccessException e ) {
64
67
return null ;
65
68
}
66
69
}
70
+
67
71
}
68
72
69
73
/**
@@ -85,6 +89,7 @@ final class CollectionExecution implements LdapQueryExecution {
85
89
public Object execute (LdapQuery query ) {
86
90
return operations .find (query , entityType );
87
91
}
92
+
88
93
}
89
94
90
95
/**
@@ -108,6 +113,7 @@ final class StreamExecution implements LdapQueryExecution {
108
113
public Object execute (LdapQuery query ) {
109
114
return operations .find (query , entityType ).stream ().map (resultProcessing ::convert );
110
115
}
116
+
111
117
}
112
118
113
119
/**
@@ -124,9 +130,12 @@ public ResultProcessingExecution(LdapQueryExecution delegate, Converter<Object,
124
130
}
125
131
126
132
@ Override
127
- public Object execute (LdapQuery query ) {
128
- return converter .convert (delegate .execute (query ));
133
+ public @ Nullable Object execute (LdapQuery query ) {
134
+
135
+ Object result = delegate .execute (query );
136
+ return result != null ? converter .convert (result ) : null ;
129
137
}
138
+
130
139
}
131
140
132
141
/**
@@ -149,7 +158,7 @@ public ResultProcessingConverter(ResultProcessor processor,
149
158
}
150
159
151
160
@ Override
152
- public Object convert (Object source ) {
161
+ public @ Nullable Object convert (@ Nullable Object source ) {
153
162
154
163
ReturnedType returnedType = processor .getReturnedType ();
155
164
@@ -165,5 +174,7 @@ public Object convert(Object source) {
165
174
166
175
return processor .processResult (source , converter );
167
176
}
177
+
168
178
}
179
+
169
180
}
0 commit comments