57 lines
1.6 KiB
Plaintext
57 lines
1.6 KiB
Plaintext
import java.io.ByteArrayOutputStream;
|
|
import java.io.DataOutputStream;
|
|
import java.io.InputStream;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.lang.IllegalStateException;
|
|
import java.io.IOException;
|
|
import java.io.DataInput;
|
|
import java.util.Arrays;
|
|
|
|
|
|
public class TdApi {
|
|
public abstract static class Object {
|
|
public native String toString();
|
|
|
|
@Override
|
|
public boolean equals(java.lang.Object o) {
|
|
if (o == null) return false;
|
|
if (o == this) return true;
|
|
if (o instanceof TdApi.Object) {
|
|
try {
|
|
return Arrays.equals(this.serialize(), ((TdApi.Object) o).serialize());
|
|
} catch (IOException ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
try {
|
|
return Arrays.hashCode(this.serialize());
|
|
} catch (IOException ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public abstract int getConstructor();
|
|
|
|
public byte[] serialize() throws IOException {
|
|
try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
|
try(DataOutputStream out = new DataOutputStream(baos)) {
|
|
serialize(out);
|
|
return baos.toByteArray();
|
|
}
|
|
}
|
|
}
|
|
|
|
public abstract void serialize(DataOutputStream out) throws IOException;
|
|
}
|
|
|
|
public abstract static class Function extends Object {
|
|
public native String toString();
|
|
}
|
|
|