Code example for Map

Methods: containsKey, get, put

0
 
    if ((canonicalAddress = getCanonicalAddressFromCache(address)) != -1)
      return canonicalAddress;
 
    canonicalAddress = getCanonicalAddressFromDatabase(address);
    addressCache.put(address, canonicalAddress);
 
    return canonicalAddress;
  } 
 
  public List<Long> getCanonicalAddresses(List<String> addresses) {
    List<Long> addressList = new LinkedList<Long>();
 
    for (String address : addresses) {
      addressList.add(getCanonicalAddress(address));
    } 
 
    return addressList;
  } 
 
  private long getCanonicalAddressFromCache(String address) {
    if (addressCache.containsKey(address))
      return Long.valueOf(addressCache.get(address));
 
    return -1L; 
  } 
 
  private long getCanonicalAddressFromDatabase(String address) {