class NotPermissionOwnerPermissionArgumentVoter extends BasicObjectPermissionArgumentVoter {

    @Override
    protected boolean isPermitted(Authentication authentication, ObjectPermission objectPermission, Object object) {
        User user = (User)authentication.getPrincipal();
        boolean res = true;

        if (objectPermission.getPermissionRecipient() instanceof User){
            User recipient = (User)objectPermission.getPermissionRecipient();
            res = !((recipient.getUsername() == user.getUsername() || recipient.getUsername().equals(user.getUsername())) &&
                   (recipient.getTenantId() == user.getTenantId() || recipient.getTenantId().equals(user.getTenantId())));
        }

        return res;
    }

}