mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Equals method must be symmetric and transitive.
This commit is contained in:
@@ -16,14 +16,14 @@ public class ContactId {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(o instanceof ContactId) return id == ((ContactId) o).id;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,37 +3,40 @@ package net.sf.briar.api.protocol;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Transport extends TreeMap<String, String> {
|
||||
|
||||
private static final long serialVersionUID = 4900420175715429560L;
|
||||
public class Transport {
|
||||
|
||||
private final TransportId id;
|
||||
private final TreeMap<String, String> properties;
|
||||
|
||||
public Transport(TransportId id, Map<String, String> p) {
|
||||
super(p);
|
||||
this.id = id;
|
||||
properties = new TreeMap<String, String>(p);
|
||||
}
|
||||
|
||||
public Transport(TransportId id) {
|
||||
super();
|
||||
this.id = id;
|
||||
properties = new TreeMap<String, String>();
|
||||
}
|
||||
|
||||
public TransportId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(o instanceof Transport) {
|
||||
Transport t = (Transport) o;
|
||||
return id.equals(t.id) && super.equals(o);
|
||||
return id.equals(t.id) && properties.equals(t.properties);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user