class RecipientIdentityResolver {

    public Object resolveRecipientObject(RecipientIdentity recipientIdentity) {
        Class<?> clazz = recipientIdentity.getRecipientClass();
        String id = recipientIdentity.getId();

        Object res = null;
        if (Role.class.equals(clazz)) {
            res = userAuthorityService.getRole(null, id);
        }
        if (User.class.equals(clazz)) {
            res = userAuthorityService.getUser(null, id);
        }
        if (Tenant.class.equals(clazz)) {
            res = tenantService.getTenant(null, id);
        }
        if (res == null) {
            throw new ResourceNotFoundException(id);
        }

        return res;
    }

}