示例#1
0
  /**
   * Add a phone to the correct operator responsible by his prefix
   *
   * @param phoneNumber The phone object to be added
   */
  public void addPhone(String operatorPrefix, String phoneNumber, AnacomData.PhoneType phoneGen) {

    Operator operator = this.getOperatorByPrefix(operatorPrefix);

    String phonePrefix = getPhonePrefixByNumber(phoneNumber);

    if (!(operator.getPrefix().equals(phonePrefix)))
      throw new PhoneAndOperatorPrefixDoNotMatchException(operator.getPrefix(), phonePrefix);

    if (phoneGen == AnacomData.PhoneType.GEN2) {
      Phone phone = new OldGenPhone(phoneNumber);
      operator.addPhone(phone);
      phone.setOperator(operator);
    } else if (phoneGen == AnacomData.PhoneType.GEN3) {
      Phone phone = new NewGenPhone(phoneNumber);
      operator.addPhone(phone);
      phone.setOperator(operator);
    }
  }
示例#2
0
  public boolean conflicts(Operator operator) {

    return (operator.getPrefix().equals(this.getPrefix()))
        && (operator.getName().equals(this.getName()));
  }
示例#3
0
  public Operator hasOperatorByPrefix(String prefix) {
    for (Operator operator : this.getOperator())
      if (operator.getPrefix().equals(prefix)) return operator;

    return null;
  }
示例#4
0
  @Override
  public boolean hasOperator(Operator operator) {
    for (Operator aux : this.getOperatorSet()) if (operator.conflicts(aux)) return true;

    return false;
  }
示例#5
0
  public void removePhone(String phoneNumber) {

    Phone phone = this.getPhone(phoneNumber);
    Operator operator = this.getOperatorByPrefix(getPhonePrefixByNumber(phoneNumber));
    operator.removePhone(phone);
  }
示例#6
0
  public Phone getPhone(String number) {

    Operator operator = getOperatorByPrefix(getPhonePrefixByNumber(number));
    return operator.getPhoneByNumber(number);
  }