@@ -143,6 +143,7 @@ private static final class ReturnedInterface extends ReturnedType {
143
143
144
144
private final ProjectionInformation information ;
145
145
private final Class <?> domainType ;
146
+ private final List <String > inputProperties ;
146
147
147
148
/**
148
149
* Creates a new {@link ReturnedInterface} from the given {@link ProjectionInformation} and domain type.
@@ -158,13 +159,28 @@ public ReturnedInterface(ProjectionInformation information, Class<?> domainType)
158
159
159
160
this .information = information ;
160
161
this .domainType = domainType ;
162
+ this .inputProperties = detectInputProperties (information );
163
+ }
164
+
165
+ private static List <String > detectInputProperties (ProjectionInformation information ) {
166
+
167
+ List <String > properties = new ArrayList <>();
168
+
169
+ for (PropertyDescriptor descriptor : information .getInputProperties ()) {
170
+ if (!properties .contains (descriptor .getName ())) {
171
+ properties .add (descriptor .getName ());
172
+ }
173
+ }
174
+
175
+ return Collections .unmodifiableList (properties );
161
176
}
162
177
163
178
@ Override
164
179
public Class <?> getReturnedType () {
165
180
return information .getType ();
166
181
}
167
182
183
+ @ Override
168
184
public boolean needsCustomConstruction () {
169
185
return isProjecting () && information .isClosed ();
170
186
}
@@ -182,16 +198,7 @@ public Class<?> getTypeToRead() {
182
198
183
199
@ Override
184
200
public List <String > getInputProperties () {
185
-
186
- List <String > properties = new ArrayList <>();
187
-
188
- for (PropertyDescriptor descriptor : information .getInputProperties ()) {
189
- if (!properties .contains (descriptor .getName ())) {
190
- properties .add (descriptor .getName ());
191
- }
192
- }
193
-
194
- return properties ;
201
+ return inputProperties ;
195
202
}
196
203
}
197
204
@@ -231,6 +238,7 @@ public Class<?> getReturnedType() {
231
238
return type ;
232
239
}
233
240
241
+ @ Override
234
242
@ NonNull
235
243
public Class <?> getTypeToRead () {
236
244
return type ;
@@ -241,6 +249,7 @@ public boolean isProjecting() {
241
249
return isDto ();
242
250
}
243
251
252
+ @ Override
244
253
public boolean needsCustomConstruction () {
245
254
return isDto () && !inputProperties .isEmpty ();
246
255
}
@@ -268,7 +277,7 @@ private List<String> detectConstructorParameterNames(Class<?> type) {
268
277
properties .add (parameter .getName ());
269
278
}
270
279
271
- return properties ;
280
+ return Collections . unmodifiableList ( properties ) ;
272
281
}
273
282
274
283
private boolean isDto () {
0 commit comments