public static boolean isEmpty(PhoneNumber phoneNumber) { if (phoneNumber == null) return true; boolean status = false; status |= StringUtils.isEmpty(phoneNumber.getArea()); status |= StringUtils.isEmpty(phoneNumber.getNumber()); status |= phoneNumber.getCountry() != Country.USA; status |= phoneNumber.getType() != PhoneLocation.HOME; return status; }
public static PhoneNumber clone(PhoneNumber phoneNumber) { if (phoneNumber == null) return null; PhoneNumber clone = create(); clone.setId(ObjectUtil.clone(phoneNumber.getId())); clone.setArea(ObjectUtil.clone(phoneNumber.getArea())); clone.setNumber(ObjectUtil.clone(phoneNumber.getNumber())); clone.setExtension(ObjectUtil.clone(phoneNumber.getExtension())); clone.setCountry(phoneNumber.getCountry()); clone.setType(phoneNumber.getType()); clone.setValue(ObjectUtil.clone(phoneNumber.getValue())); return clone; }
public static boolean validate(PhoneNumber phoneNumber) { if (phoneNumber == null) return false; Validator validator = Validator.getValidator(); validator.notEmpty(phoneNumber.getArea(), "\"Area\" must be specified"); validator.notNull(phoneNumber.getCountry(), "\"Country\" must be specified"); validator.notEmpty(phoneNumber.getNumber(), "\"Number\" must be specified"); validator.notNull(phoneNumber.getType(), "\"Type\" must be specified"); validator.notNull( phoneNumber.getArea().length() != 3, "\"Area\" must have length 3: " + phoneNumber.getArea()); validator.notNull( phoneNumber.getNumber().length() != 7, "\"Number\" must have length 7: " + phoneNumber.getNumber()); boolean isValid = validator.isValid(); return isValid; }
public static void initialize(PhoneNumber phoneNumber) { if (phoneNumber.getCountry() == null) phoneNumber.setCountry(Country.USA); if (phoneNumber.getType() == null) phoneNumber.setType(PhoneLocation.HOME); }