What is the equivalent of hook_user_view()? I am basically trying to do what described in How can I let anonymous users view user profiles by role? in Drupal 8. User profiles should only be visible to anonymous users only if those profiles are for users having a certain role; all the other user profiles should not be accessible to anonymous.

The answer there suggests using hook_user_view(), but it appears that hook has been removed in Drupal 8. Is there a different/correct way to do this now?
hook_user_view() is still available in drupal 8, but the hook naming schema has changed, because the hook can now be used for all entity types:

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_ENTITY_TYPE_view/8.2.x

A more D8 way to do this could be a custom access check on the route:

https://www.drupal.org/node/2122195