class PersistableClassValidator {

    public List<ValidationMessage> validate( String className, ClassLoader classLoader ) {
        List<ValidationMessage> result = new ArrayList<>( );
        Class< ? > clazz;
        try {
            if ( className == null || className.trim( ).isEmpty( ) ) {
                result.add( newErrorMessage( PersistenceDescriptorValidationMessages.PERSISTABLE_CLASS_NAME_EMPTY_ID,
                        PersistenceDescriptorValidationMessages.PERSISTABLE_CLASS_NAME_EMPTY ) );
                return result;
            }
            clazz = classLoader.loadClass( className );
            Annotation[] annotations = clazz.getAnnotations( );
            Optional< Annotation > persistable = Arrays.stream( annotations )
                    .filter( annotation ->
                            Entity.class.equals( annotation.annotationType( ) ) ||
                                    Embeddable.class.equals( annotation.annotationType( ) ) ||
                                    MappedSuperclass.class.equals( annotation.annotationType( ) ) )
                    .findFirst( );
            if ( !persistable.isPresent( ) ) {
                result.add( newErrorMessage( PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE_ID,
                        MessageFormat.format( PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE, className ), className ) );
            }
        } catch ( ClassNotFoundException e ) {
            result.add( newErrorMessage( PersistenceDescriptorValidationMessages.CLASS_NOT_FOUND_ID,
                    MessageFormat.format( PersistenceDescriptorValidationMessages.CLASS_NOT_FOUND, className ), className ) );
        }
        return result;
    }

    public  PersistableClassValidator( );

}