tdlib-serializer/headers.txt

89 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2020-05-01 15:39:29 +02:00
import java.io.ByteArrayOutputStream;
2021-01-26 23:01:52 +01:00
import java.io.DataOutput;
2020-05-01 15:39:29 +02:00
import java.io.DataOutputStream;
import java.nio.charset.StandardCharsets;
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-10-16 22:12:42 +02:00
import java.util.Objects;
2020-05-01 15:39:29 +02:00
/**
* This class contains as static nested classes all other TDLib interface
* type-classes and function-classes.
* <p>
* It has no inner classes, functions or public members.
*/
2021-10-23 18:12:46 +02:00
public final class TdApi {
private TdApi() {}
/**
* This class is a base class for all TDLib interface classes.
*/
2021-10-23 18:06:47 +02:00
public abstract static class Object {
/**
* Returns a string representation of the object.
*
* @return a string representation of the object.
*/
2021-10-23 18:06:47 +02:00
public native String toString();
2020-05-01 15:39:29 +02:00
/**
* Returns an identifier uniquely determining type of the object.
*
* @return a unique identifier of the object type.
*/
2021-10-23 18:06:47 +02:00
public abstract int getConstructor();
2020-05-01 15:39:29 +02:00
/**
* Default Object constructor.
*/
2021-10-23 18:16:46 +02:00
private Object() {}
/**
* Serialize the object.
*
* @return the current object serialized into a byte[].
* @throws IOException the serialization failed
*/
2021-10-23 18:06:47 +02:00
public byte[] serialize() throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
try (DataOutputStream out = new DataOutputStream(baos)) {
serialize(out);
return baos.toByteArray();
}
}
}
2020-05-01 15:39:29 +02:00
/**
* Serialize the object.
*
* @param out the output in which the object is serialized.
* @throws IOException the serialization failed
*/
2021-10-23 18:06:47 +02:00
public abstract void serialize(DataOutput out) throws IOException;
2021-10-23 18:06:47 +02:00
}
2020-05-01 15:39:29 +02:00
/**
* This class is a base class for all TDLib interface function-classes.
* @param <R> The function return type
*/
2021-10-23 18:06:47 +02:00
public abstract static class Function<R extends TdApi.Object> extends TdApi.Object {
/**
* Default Function constructor.
*/
2021-10-23 18:16:46 +02:00
private Function() {}
/**
* Returns a string representation of the object.
*
* @return a string representation of the object.
*/
2021-10-23 18:06:47 +02:00
public native String toString();
}
2021-10-23 18:06:47 +02:00