@@ -447,10 +447,8 @@ public void setPersistentPropertyAccessorFactory(PersistentPropertyAccessorFacto
447
447
public PersistentPropertyAccessor getPropertyAccessor (Object bean ) {
448
448
449
449
Assert .notNull (bean , "Target bean must not be null!" );
450
-
451
- if (!getType ().isInstance (bean )) { // prevent capturing lambda
452
- throw new IllegalArgumentException (String .format (TYPE_MISMATCH , bean .getClass ().getName (), getType ().getName ()));
453
- }
450
+ Assert .isTrue (getType ().isInstance (bean ),
451
+ () -> String .format (TYPE_MISMATCH , bean .getClass ().getName (), getType ().getName ()));
454
452
455
453
return propertyAccessorFactory .getPropertyAccessor (this , bean );
456
454
}
@@ -463,10 +461,8 @@ public PersistentPropertyAccessor getPropertyAccessor(Object bean) {
463
461
public IdentifierAccessor getIdentifierAccessor (Object bean ) {
464
462
465
463
Assert .notNull (bean , "Target bean must not be null!" );
466
-
467
- if (!getType ().isInstance (bean )) { // prevent capturing lambda
468
- throw new IllegalArgumentException (String .format (TYPE_MISMATCH , bean .getClass ().getName (), getType ().getName ()));
469
- }
464
+ Assert .isTrue (getType ().isInstance (bean ),
465
+ () -> String .format (TYPE_MISMATCH , bean .getClass ().getName (), getType ().getName ()));
470
466
471
467
return hasIdProperty () ? new IdPropertyIdentifierAccessor (this , bean ) : new AbsentIdentifierAccessor (bean );
472
468
}
0 commit comments