/** * {@inheritDoc} */ @Override public List<? extends DNSEntry> put(String key, List<? extends DNSEntry> value) { synchronized (this) { List<? extends DNSEntry> oldValue = null; Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(key); if (oldEntry != null) { oldValue = oldEntry.setValue(value); } else { this.entrySet().add(new _CacheEntry(key, value)); } return oldValue; } }
/** * Removes a specific entry from the table. Returns true if the entry was found. * * @param dnsEntry * @return true if the entry was removed */ public synchronized boolean removeDNSEntry(DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { Map.Entry<String, List<? extends DNSEntry>> existingEntry = this.getEntry(dnsEntry.getKey()); if (existingEntry != null) { result = existingEntry.getValue().remove(dnsEntry); // If we just removed the last one we need to get rid of the entry if (existingEntry.getValue().isEmpty()) { this.entrySet().remove(existingEntry); } } } return result; }
/** * Removes a specific entry from the table. Returns true if the entry was found. * * @param dnsEntry * @return true if the entry was removed */ public synchronized boolean removeDNSEntry(DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { Map.Entry<String, List<? extends DNSEntry>> existingEntry = this.getEntry(dnsEntry.getKey()); if (existingEntry != null) { result = existingEntry.getValue().remove(dnsEntry); // If we just removed the last one we need to get rid of the entry if (existingEntry.getValue().isEmpty()) { this.entrySet().remove(existingEntry); } } } return result; }
/** * {@inheritDoc} */ @Override public List<? extends DNSEntry> put(String key, List<? extends DNSEntry> value) { synchronized (this) { List<? extends DNSEntry> oldValue = null; Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(key); if (oldEntry != null) { oldValue = oldEntry.setValue(value); } else { this.entrySet().add(new _CacheEntry(key, value)); } return oldValue; } }
/** * Removes a specific entry from the table. Returns true if the entry was found. * * @param dnsEntry * @return true if the entry was removed */ public synchronized boolean removeDNSEntry(DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { Map.Entry<String, List<? extends DNSEntry>> existingEntry = this.getEntry(dnsEntry.getKey()); if (existingEntry != null) { result = existingEntry.getValue().remove(dnsEntry); // If we just removed the last one we need to get rid of the entry if (existingEntry.getValue().isEmpty()) { this.entrySet().remove(existingEntry); } } } return result; }
/** * {@inheritDoc} */ @Override public List<? extends DNSEntry> put(String key, List<? extends DNSEntry> value) { synchronized (this) { List<? extends DNSEntry> oldValue = null; Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(key); if (oldEntry != null) { oldValue = oldEntry.setValue(value); } else { this.entrySet().add(new _CacheEntry(key, value)); } return oldValue; } }
/** * Adds an entry to the table. * * @param dnsEntry * @return true if the entry was added */ public synchronized boolean addDNSEntry(final DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(dnsEntry.getKey()); List<DNSEntry> aNewValue = null; if (oldEntry != null) { aNewValue = new ArrayList<DNSEntry>(oldEntry.getValue()); } else { aNewValue = new ArrayList<DNSEntry>(); } aNewValue.add(dnsEntry); if (oldEntry != null) { oldEntry.setValue(aNewValue); } else { this.entrySet().add(new _CacheEntry(dnsEntry.getKey(), aNewValue)); } // This is probably not very informative result = true; } return result; }
/** * Adds an entry to the table. * * @param dnsEntry * @return true if the entry was added */ public synchronized boolean addDNSEntry(final DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(dnsEntry.getKey()); List<DNSEntry> aNewValue = null; if (oldEntry != null) { aNewValue = new ArrayList<DNSEntry>(oldEntry.getValue()); } else { aNewValue = new ArrayList<DNSEntry>(); } aNewValue.add(dnsEntry); if (oldEntry != null) { oldEntry.setValue(aNewValue); } else { this.entrySet().add(new _CacheEntry(dnsEntry.getKey(), aNewValue)); } // This is probably not very informative result = true; } return result; }
/** * Adds an entry to the table. * * @param dnsEntry * @return true if the entry was added */ public synchronized boolean addDNSEntry(final DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(dnsEntry.getKey()); List<DNSEntry> aNewValue = null; if (oldEntry != null) { aNewValue = new ArrayList<DNSEntry>(oldEntry.getValue()); } else { aNewValue = new ArrayList<DNSEntry>(); } aNewValue.add(dnsEntry); if (oldEntry != null) { oldEntry.setValue(aNewValue); } else { this.entrySet().add(new _CacheEntry(dnsEntry.getKey(), aNewValue)); } // This is probably not very informative result = true; } return result; }
/** * Replace an existing entry by a new one.<br/> * <b>Note:</b> the 2 entries must have the same key. * * @param newDNSEntry * @param existingDNSEntry * @return <code>true</code> if the entry has been replace, <code>false</code> otherwise. */ public synchronized boolean replaceDNSEntry(DNSEntry newDNSEntry, DNSEntry existingDNSEntry) { boolean result = false; if ((newDNSEntry != null) && (existingDNSEntry != null) && (newDNSEntry.getKey().equals(existingDNSEntry.getKey()))) { Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(newDNSEntry.getKey()); List<DNSEntry> aNewValue = null; if (oldEntry != null) { aNewValue = new ArrayList<DNSEntry>(oldEntry.getValue()); } else { aNewValue = new ArrayList<DNSEntry>(); } aNewValue.remove(existingDNSEntry); aNewValue.add(newDNSEntry); if (oldEntry != null) { oldEntry.setValue(aNewValue); } else { this.entrySet().add(new _CacheEntry(newDNSEntry.getKey(), aNewValue)); } // This is probably not very informative result = true; } return result; }
/** * Replace an existing entry by a new one.<br/> * <b>Note:</b> the 2 entries must have the same key. * * @param newDNSEntry * @param existingDNSEntry * @return <code>true</code> if the entry has been replace, <code>false</code> otherwise. */ public synchronized boolean replaceDNSEntry(DNSEntry newDNSEntry, DNSEntry existingDNSEntry) { boolean result = false; if ((newDNSEntry != null) && (existingDNSEntry != null) && (newDNSEntry.getKey().equals(existingDNSEntry.getKey()))) { Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(newDNSEntry.getKey()); List<DNSEntry> aNewValue = null; if (oldEntry != null) { aNewValue = new ArrayList<DNSEntry>(oldEntry.getValue()); } else { aNewValue = new ArrayList<DNSEntry>(); } aNewValue.remove(existingDNSEntry); aNewValue.add(newDNSEntry); if (oldEntry != null) { oldEntry.setValue(aNewValue); } else { this.entrySet().add(new _CacheEntry(newDNSEntry.getKey(), aNewValue)); } // This is probably not very informative result = true; } return result; }
/** * Replace an existing entry by a new one.<br/> * <b>Note:</b> the 2 entries must have the same key. * * @param newDNSEntry * @param existingDNSEntry * @return <code>true</code> if the entry has been replace, <code>false</code> otherwise. */ public synchronized boolean replaceDNSEntry(DNSEntry newDNSEntry, DNSEntry existingDNSEntry) { boolean result = false; if ((newDNSEntry != null) && (existingDNSEntry != null) && (newDNSEntry.getKey().equals(existingDNSEntry.getKey()))) { Map.Entry<String, List<? extends DNSEntry>> oldEntry = this.getEntry(newDNSEntry.getKey()); List<DNSEntry> aNewValue = null; if (oldEntry != null) { aNewValue = new ArrayList<DNSEntry>(oldEntry.getValue()); } else { aNewValue = new ArrayList<DNSEntry>(); } aNewValue.remove(existingDNSEntry); aNewValue.add(newDNSEntry); if (oldEntry != null) { oldEntry.setValue(aNewValue); } else { this.entrySet().add(new _CacheEntry(newDNSEntry.getKey(), aNewValue)); } // This is probably not very informative result = true; } return result; }