Implements (poor) hashCode() for CandidatePair and Candidate so they may at least be added to HashMap.
This commit is contained in:
parent
8230c3d69f
commit
eb0e3d3fb8
@ -341,6 +341,20 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
&& getFoundation().equals(candidate.getFoundation());
|
&& getFoundation().equals(candidate.getFoundation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
// Even if the following hashCode algorithm has drawbacks because of it
|
||||||
|
// simplicity, it is better than nothing because at least it allows
|
||||||
|
// Candidate and, respectively, CandidatePair to be used as HashMap
|
||||||
|
// keys.
|
||||||
|
return
|
||||||
|
getParentComponent().hashCode() + getTransportAddress().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the <tt>Component</tt> that this candidate belongs
|
* Returns a reference to the <tt>Component</tt> that this candidate belongs
|
||||||
* to.
|
* to.
|
||||||
|
|||||||
@ -456,6 +456,20 @@ public class CandidatePair
|
|||||||
&& remoteCandidate.equals(candidatePair.remoteCandidate);
|
&& remoteCandidate.equals(candidatePair.remoteCandidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
// Even if the following hashCode algorithm has drawbacks because of it
|
||||||
|
// simplicity, it is better than nothing because at least it allows
|
||||||
|
// CandidatePair to be used as a HashMap key.
|
||||||
|
// XXX While localCandidate is not final, the parentComponent is
|
||||||
|
// supposedly effectively final.
|
||||||
|
return getLocalCandidate().getParentComponent().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a String representation of this <tt>CandidatePair</tt>.
|
* Returns a String representation of this <tt>CandidatePair</tt>.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user