コード例 #1
0
  public void removePhoneNumber(TelephoneNumber telephoneNumber) {
    Enumeration keys = ((Hashtable) telephoneNumbers).keys();
    while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      TelephoneNumber potentialTelephoneNumber = telephoneNumbers.get(key);

      if (potentialTelephoneNumber.equals(telephoneNumber)) {
        telephoneNumbers.remove(key);
        potentialTelephoneNumber.setBeerConsumer(null);
        return;
      }
    }
  }
コード例 #2
0
 /**
  * This model requires that a BeerConsumer be persisted prior to assigning him/her a telephone
  * number. This is because the BeerConsumer id is part of the composite primary key, and that key
  * is needed for the map that holds the telephone numbers.
  */
 public void addTelephoneNumber(TelephoneNumber telephoneNumber) {
   telephoneNumber.setBeerConsumer(this);
   telephoneNumbers.put(telephoneNumber.buildPK(), telephoneNumber);
 }