Moved AnnotationBeanNameGenerator's String value check right before cast

Issue: SPR-11221
Polishing

Issue: SPR-11221