I need to write something like this:
private Set processedLinks = new HashSet(); public boolean isProcessed(String url) throws MalformedURLException { return processedLinks.contains(new URL(url)); } This doesn't work, because created URL is another object than URL in collection. I need to compare match of host and file of created URL with URLs in HashSet. What is the best way?
I wanted to extend URL with my class and override equals(), but URL is final. So the second idea I have is to make something like URLHashSet extends HashSet and override contains method. But I'm not sure if it wouldn't have negative effect to performance, because that HashSet will contains tens of thousands elements.
Do you have please some idea how to resolve this? Thanks.