Java's equality is stupid
This commit is contained in:
parent
d0e6e89ffb
commit
3ce415e106
|
@ -59,7 +59,7 @@ public class ServerApi {
|
||||||
public synchronized Object create(String nodeClassName, Object arg) throws InterruptedException, SexpSyntaxError {
|
public synchronized Object create(String nodeClassName, Object arg) throws InterruptedException, SexpSyntaxError {
|
||||||
send("factory", SexpMessage.create(nodeClassName, arg, _container.getName(), _kName));
|
send("factory", SexpMessage.create(nodeClassName, arg, _container.getName(), _kName));
|
||||||
SexpList reply = _nextReply();
|
SexpList reply = _nextReply();
|
||||||
String selector = reply.getBytes(0).getDataString();
|
SexpBytes selector = reply.getBytes(0);
|
||||||
if (selector.equals(SexpMessage._create_ok)) return null;
|
if (selector.equals(SexpMessage._create_ok)) return null;
|
||||||
assert selector.equals(SexpMessage._create_failed);
|
assert selector.equals(SexpMessage._create_failed);
|
||||||
return reply.get(1);
|
return reply.get(1);
|
||||||
|
|
|
@ -6,6 +6,7 @@ package hop;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -31,4 +32,13 @@ public class SexpBytes {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return SexpWriter.writeString(this);
|
return SexpWriter.writeString(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return (other instanceof SexpBytes) &&
|
||||||
|
Arrays.equals(_bytes, ((SexpBytes) other).getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return Arrays.hashCode(_bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue