/** * Adds an entry to the table. * * @param dnsEntry * @return true if the entry was added */ public boolean addDNSEntry(final DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { List<DNSEntry> entryList = this.get(dnsEntry.getKey()); if (entryList == null) { this.putIfAbsent(dnsEntry.getKey(), new ArrayList<DNSEntry>()); entryList = this.get(dnsEntry.getKey()); } synchronized (entryList) { entryList.add(dnsEntry); } // 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 boolean replaceDNSEntry(DNSEntry newDNSEntry, DNSEntry existingDNSEntry) { boolean result = false; if ((newDNSEntry != null) && (existingDNSEntry != null) && (newDNSEntry.getKey().equals(existingDNSEntry.getKey()))) { List<DNSEntry> entryList = this.get(newDNSEntry.getKey()); if (entryList == null) { this.putIfAbsent(newDNSEntry.getKey(), new ArrayList<DNSEntry>()); entryList = this.get(newDNSEntry.getKey()); } synchronized (entryList) { entryList.remove(existingDNSEntry); entryList.add(newDNSEntry); } // This is probably not very informative result = true; } return result; }