a and (b or c) <==> (a and b) or (a and c)
UserExample userExample = new UserExample();
String email = user.getEmail();
String telephone = user.getTelephone();
userExample.createCriteria().andIdNotEqualTo(userId).andEmailEqualTo(email);//(id != 'a' and email = 'b')
if (StringUtils.isNotBlank(telephone)) {
Criteria criteria = userExample.createCriteria().andIdNotEqualTo(userId).andTelephoneEqualTo(telephone);//(id != 'a' and telephone = 'c')
userExample.or(criteria);//(id != 'a' and email = 'b') or (id != 'a' and telephone = 'c')
}
List<User> userList = userService.selectByExample(userExample);