Skip to content

Conversation

@vkryl
Copy link
Contributor

@vkryl vkryl commented Oct 26, 2023

This PR includes:

  • Strongly typed Client.send methods, callback parameter type of which is based on the return type declared in TdApi.Function child class, which allow compile-time protection against return type changes, avoiding casts on caller side, etc. Weakly typed send methods remain unchanged for compatibility purposes.
  • Client.send method without any callbacks. The only reason for it is because client.send(function, null) will now cause compile error
  • Warning fix for raw parametrized use of TdApi.Function
  • Small documentation fix in Client.java

This allows using the following pattern when executing methods in Java:

client.send(new TdApi.SpecificReturnTypeFunction(), (typedResult, error) -> {
  if (error != null) {
    // handle error
  } else {
    // work with typedResult without any casting
  }
});

vkryl added 5 commits October 26, 2023 16:41
Added new strongly typed methods to Java interface, which allow complie-time protection against function return type changes and avoiding type casting on caller side
When `resultHandler` is null, nothing is called
@vkryl vkryl changed the title Strongly typed asynchronous send methods in Java layer Strongly typed API for asynchronous TDLib method execution in Java interface Oct 26, 2023
Copy link

@A-Abdurashid A-Abdurashid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants