public boolean truncateTooLongNumber(PhoneNumber number){
  if (isValidNumber(number)) {
    return true;
  }
  PhoneNumber numberCopy=new PhoneNumber();
  numberCopy.mergeFrom(number);
  long nationalNumber=number.getNationalNumber();
  do {
    nationalNumber/=10;
    numberCopy.setNationalNumber(nationalNumber);
    if (isPossibleNumberWithReason(numberCopy) == ValidationResult.TOO_SHORT || nationalNumber == 0) {
      return false;
    }
  }
 while (!isValidNumber(numberCopy));
  number.setNationalNumber(nationalNumber);
  return true;
}

public boolean truncateTooLongNumber ( PhoneNumber number ) { if ( isValidNumber ( number ) ) { return true ; } PhoneNumber numberCopy = new PhoneNumber ( ) ; numberCopy . mergeFrom ( number ) ; long nationalNumber = number . getNationalNumber ( ) ; do { nationalNumber /= 10 ; numberCopy . setNationalNumber ( nationalNumber ) ; if ( isPossibleNumberWithReason ( numberCopy ) == ValidationResult . TOO_SHORT || nationalNumber == 0 ) { return false ; } } while ( ! isValidNumber ( numberCopy ) ) ; number . setNationalNumber ( nationalNumber ) ; return true ; }
attempts to extract a valid number from a phone number that is too long to be valid , and resets the phonenumber object passed in to that valid version . if no valid number could be extracted , the phonenumber object passed in will not be modified .
