@@ -193,32 +193,31 @@ public SchemaTransformer createSchemaTransformer(TypeDefinitionRegistry registry
193
193
private void checkEntityMappings (TypeDefinitionRegistry registry ) {
194
194
List <String > unmappedEntities = new ArrayList <>();
195
195
for (TypeDefinition <?> type : registry .types ().values ()) {
196
- if (isEntityMappingExpected (type ) && !this .handlerMethods .containsKey (type .getName ())) {
197
- unmappedEntities .add (type .getName ());
198
- }
196
+ type .getDirectives ().forEach ((directive ) -> {
197
+ if (isResolvableKeyDirective (directive ) && !this .handlerMethods .containsKey (type .getName ())) {
198
+ unmappedEntities .add (type .getName ());
199
+ }
200
+ });
199
201
}
200
202
if (!unmappedEntities .isEmpty ()) {
201
203
throw new IllegalStateException ("Unmapped entity types: " +
202
204
unmappedEntities .stream ().collect (Collectors .joining ("', '" , "'" , "'" )));
203
205
}
204
206
}
205
207
206
- /**
207
- * Determine if a handler method is expected for this type: there is at least one '@key' directive
208
- * whose 'resolvable' argument resolves to true (either explicitly, or if the argument is not set).
209
- * @param type the type to inspect.
210
- * @return true if a handler method is expected for this type
211
- */
212
- private boolean isEntityMappingExpected (TypeDefinition <?> type ) {
213
- List <Directive > keyDirectives = type .getDirectives ("key" );
214
- return !keyDirectives .isEmpty () && keyDirectives .stream ()
215
- .anyMatch ((keyDirective ) -> {
216
- Argument resolvableArg = keyDirective .getArgument ("resolvable" );
217
- return resolvableArg == null ||
218
- (resolvableArg .getValue () instanceof BooleanValue ) && ((BooleanValue ) resolvableArg .getValue ()).isValue ();
219
- });
208
+ private boolean isResolvableKeyDirective (Directive directive ) {
209
+ if (!directive .getName ().equalsIgnoreCase ("key" )) {
210
+ return false ;
211
+ }
212
+ Argument argument = directive .getArgument ("resolvable" );
213
+ if (argument != null ) {
214
+ Object value = argument .getValue ();
215
+ return (value instanceof BooleanValue bv && bv .isValue ());
216
+ }
217
+ return true ;
220
218
}
221
219
220
+
222
221
public record EntityMappingInfo (String typeName , HandlerMethod handlerMethod ) {
223
222
224
223
public boolean isBatchHandlerMethod () {
0 commit comments