Ejemplo n.º 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);
    }
  }
Ejemplo n.º 2
0
  public boolean conflicts(Operator operator) {

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

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

    return false;
  }
Ejemplo n.º 5
0
  public void removePhone(String phoneNumber) {

    Phone phone = this.getPhone(phoneNumber);
    Operator operator = this.getOperatorByPrefix(getPhonePrefixByNumber(phoneNumber));
    operator.removePhone(phone);
  }
Ejemplo n.º 6
0
  public Phone getPhone(String number) {

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