public PhoneNumber build()

in scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/resources/PhoneNumber.java [674:711]


    public PhoneNumber build() throws PhoneNumberParseException {
      if (StringUtils.isBlank(subscriberNumber) || !subscriberNumber.matches(LOCAL_SUBSCRIBER_NUMBER_REGEX)) {
        throw new IllegalArgumentException("LocalPhoneNumberBuilder subscriberNumber must contain only numeric characters and optional ., -, (, ) visual separator characters.");
      }

      if (StringUtils.isBlank(countryCode) && StringUtils.isBlank(domainName)) {
        throw new IllegalArgumentException("LocalPhoneNumberBuilder must have values for domainName or countryCode.");
      }

      if (StringUtils.isBlank(domainName)) {
        if (StringUtils.isBlank(countryCode) || !countryCode.matches(COUNTRY_CODE_REGEX)) {
          throw new IllegalArgumentException("LocalPhoneNumberBuilder countryCode must contain only numeric characters and an optional plus (+) prefix.");
        }

        if (areaCode != null && !StringUtils.isNumeric(areaCode)) {
          throw new IllegalArgumentException("LocalPhoneNumberBuilder areaCode must contain only numberic characters.");
        }

        if (!countryCode.startsWith(INTERNATIONAL_PREFIX)) {
          this.phoneContext = INTERNATIONAL_PREFIX + countryCode;
        } else {
          this.phoneContext = countryCode;
        }

        if (!StringUtils.isBlank(areaCode)) {
          this.phoneContext += (HYPHEN + areaCode);
        }

      } else {
        if (!domainName.matches(DOMAIN_NAME_REGEX)) {
          throw new IllegalArgumentException("LocalPhoneNumberBuilder domainName must contain only alphanumeric, . and - characters.");
        }

        this.phoneContext = domainName;
      }

      return super.build();
    }