tdlib-serializer/headers.txt

57 lines
1.6 KiB
Plaintext
Raw Normal View History

2020-05-01 15:39:29 +02:00
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
2020-05-02 19:39:54 +02:00
import java.io.InputStream;
2020-05-01 15:39:29 +02:00
import java.nio.charset.StandardCharsets;
import java.lang.IllegalStateException;
import java.io.IOException;
2020-05-14 21:59:50 +02:00
import java.io.DataInput;
2020-10-15 11:38:01 +02:00
import java.util.Arrays;
2020-05-01 15:39:29 +02:00
public class TdApi {
public abstract static class Object {
public native String toString();
2020-10-15 11:50:09 +02:00
@Override
public boolean equals(java.lang.Object o) {
2020-10-15 11:38:01 +02:00
if (o == null) return false;
if (o == this) return true;
2020-10-15 11:50:09 +02:00
if (o instanceof TdApi.Object) {
2020-10-15 11:42:07 +02:00
try {
2020-10-15 11:50:09 +02:00
return Arrays.equals(this.serialize(), ((TdApi.Object) o).serialize());
2020-10-15 11:42:07 +02:00
} catch (IOException ex) {
ex.printStackTrace();
}
2020-10-15 11:38:01 +02:00
}
return false;
}
2020-10-15 11:50:09 +02:00
@Override
2020-10-15 11:38:01 +02:00
public int hashCode() {
2020-10-15 11:42:07 +02:00
try {
return Arrays.hashCode(this.serialize());
} catch (IOException ex) {
ex.printStackTrace();
}
return 0;
2020-10-15 11:38:01 +02:00
}
2020-05-01 15:39:29 +02:00
public abstract int getConstructor();
public byte[] serialize() throws IOException {
2020-08-20 14:05:18 +02:00
try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
try(DataOutputStream out = new DataOutputStream(baos)) {
2020-05-01 15:39:29 +02:00
serialize(out);
return baos.toByteArray();
}
}
}
public abstract void serialize(DataOutputStream out) throws IOException;
}
public abstract static class Function extends Object {
public native String toString();
}