public PhoneNumber build()

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


    public PhoneNumber build(boolean validate) throws PhoneNumberParseException {
      if (!StringUtils.isBlank(extension) && !StringUtils.isBlank(subAddress)) {
        throw new IllegalArgumentException("PhoneNumberBuilder cannot have a value for both extension and subAddress.");
      }

      if (extension != null && !extension.matches(LOCAL_SUBSCRIBER_NUMBER_REGEX)) {
        throw new IllegalArgumentException("PhoneNumberBuilder extension must contain only numeric characters and optional ., -, (, ) visual separator characters.");
      }

      if (params != null && !params.isEmpty()) {
        if (params.get("") != null || params.get(null) != null || params.containsValue(null) || params.containsValue("")) { //NOPMD - suppressed CollapsibleIfStatements
          throw new IllegalArgumentException("PhoneNumberBuilder params names and values cannot be null or empty.");
        }
      }

      PhoneNumber phoneNumber = new PhoneNumber();
      String formattedValue = getFormattedValue();
      LOGGER.debug("Building phone number: '{}'", formattedValue);

      if (validate) {
        phoneNumber.setValue(formattedValue, true);
      } else {
        phoneNumber.value = formattedValue;
        phoneNumber.extension = this.extension;
        phoneNumber.isDomainPhoneContext = this.isDomainPhoneContext;
        phoneNumber.isGlobalNumber = this.isGlobalNumber;
        phoneNumber.number = this.number;
        phoneNumber.params = this.params;
        phoneNumber.phoneContext = this.phoneContext;
        phoneNumber.subAddress = this.subAddress;
      }
      return phoneNumber;
    }