/** * Removes a specific entry from the table. Returns true if the entry was found. * * @param dnsEntry * @return true if the entry was removed */ public boolean removeDNSEntry(DNSEntry dnsEntry) { boolean result = false; if (dnsEntry != null) { List<DNSEntry> entryList = this.get(dnsEntry.getKey()); if (entryList != null) { synchronized (entryList) { entryList.remove(dnsEntry); } } } return result; }
/** * 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; }
/** * Check if two entries have exactly the same name, type, and class. * * @param entry * @return <code>true</code> if the two entries have are for the same record, <code>false</code> otherwise */ public boolean isSameEntry(DNSEntry entry) { return this.getKey().equals(entry.getKey()) && this.matchRecordType(entry.getRecordType()) && this.matchRecordClass(entry.getRecordClass()); }
/** * 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; }
/** * 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; }
@Override public boolean equals(Object obj) { boolean result = false; if (obj instanceof DNSEntry) { DNSEntry other = (DNSEntry) obj; result = this.getKey().equals(other.getKey()) && this.getRecordType().equals(other.getRecordType()) && this.getRecordClass() == other.getRecordClass(); } return result; }
@Override public boolean equals(Object obj) { boolean result = false; if (obj instanceof DNSEntry) { DNSEntry other = (DNSEntry) obj; result = this.getKey().equals(other.getKey()) && this.getRecordType().equals(other.getRecordType()) && this.getRecordClass() == other.getRecordClass(); } return result; }
@Override public boolean equals(Object obj) { boolean result = false; if (obj instanceof DNSEntry) { DNSEntry other = (DNSEntry) obj; result = this.getKey().equals(other.getKey()) && this.getRecordType().equals(other.getRecordType()) && this.getRecordClass() == other.getRecordClass(); } return result; }
@Override public boolean equals(Object obj) { boolean result = false; if (obj instanceof DNSEntry) { DNSEntry other = (DNSEntry) obj; result = this.getKey().equals(other.getKey()) && this.getRecordType().equals(other.getRecordType()) && this.getRecordClass() == other.getRecordClass(); } return result; }
/** * Get a matching DNS entry from the table (using isSameEntry). Returns the entry that was found. * * @param dnsEntry * @return DNSEntry */ public synchronized DNSEntry getDNSEntry(DNSEntry dnsEntry) { DNSEntry result = null; if (dnsEntry != null) { Collection<? extends DNSEntry> entryList = this.getDNSEntryList(dnsEntry.getKey()); if (entryList != null) { for (DNSEntry testDNSEntry : entryList) { if (testDNSEntry.isSameEntry(dnsEntry)) { result = testDNSEntry; break; } } } } return result; }
/** * Overriden, to return a value which is consistent with the value returned by equals(Object). */ @Override public int hashCode() { return this.getKey().hashCode() + this.getRecordType().indexValue() + this.getRecordClass().indexValue(); }
/** * Get a matching DNS entry from the table (using isSameEntry). Returns the entry that was found. * * @param dnsEntry * @return DNSEntry */ public synchronized DNSEntry getDNSEntry(DNSEntry dnsEntry) { DNSEntry result = null; if (dnsEntry != null) { Collection<? extends DNSEntry> entryList = this._getDNSEntryList(dnsEntry.getKey()); if (entryList != null) { for (DNSEntry testDNSEntry : entryList) { if (testDNSEntry.isSameEntry(dnsEntry)) { result = testDNSEntry; break; } } } } return result; }
/** * Overriden, to return a value which is consistent with the value returned by equals(Object). */ @Override public int hashCode() { return this.getKey().hashCode() + this.getRecordType().indexValue() + this.getRecordClass().indexValue(); }
/** * Get a matching DNS entry from the table (using isSameEntry). Returns the entry that was found. * * @param dnsEntry * @return DNSEntry */ public synchronized DNSEntry getDNSEntry(DNSEntry dnsEntry) { DNSEntry result = null; if (dnsEntry != null) { Collection<? extends DNSEntry> entryList = this._getDNSEntryList(dnsEntry.getKey()); if (entryList != null) { for (DNSEntry testDNSEntry : entryList) { if (testDNSEntry.isSameEntry(dnsEntry)) { result = testDNSEntry; break; } } } } return result; }
/** * Check if two entries have exactly the same name, type, and class. * * @param entry * @return <code>true</code> if the two entries have are for the same record, <code>false</code> otherwise */ public boolean isSameEntry(DNSEntry entry) { return this.getKey().equals(entry.getKey()) && this.getRecordType().equals(entry.getRecordType()) && ((DNSRecordClass.CLASS_ANY == entry.getRecordClass()) || this.getRecordClass().equals(entry.getRecordClass())); }
/** * Overriden, to return a value which is consistent with the value returned by equals(Object). */ @Override public int hashCode() { return this.getKey().hashCode() + this.getRecordType().indexValue() + this.getRecordClass().indexValue(); }
/** * Overriden, to return a value which is consistent with the value returned by equals(Object). */ @Override public int hashCode() { return this.getKey().hashCode() + this.getRecordType().indexValue() + this.getRecordClass().indexValue(); }
/** * Check if two entries have exactly the same name, type, and class. * * @param entry * @return <code>true</code> if the two entries have are for the same record, <code>false</code> otherwise */ public boolean isSameEntry(DNSEntry entry) { return this.getKey().equals(entry.getKey()) && this.getRecordType().equals(entry.getRecordType()) && ((DNSRecordClass.CLASS_ANY == entry.getRecordClass()) || this.getRecordClass().equals(entry.getRecordClass())); }
/** * Check if two entries have exactly the same name, type, and class. * * @param entry * @return <code>true</code> if the two entries have are for the same record, <code>false</code> otherwise */ public boolean isSameEntry(DNSEntry entry) { return this.getKey().equals(entry.getKey()) && this.getRecordType().equals(entry.getRecordType()) && ((DNSRecordClass.CLASS_ANY == entry.getRecordClass()) || this.getRecordClass().equals(entry.getRecordClass())); }