Refactor setting of touch actions options by mykola-mokhnach · Pull Request #756 · appium/java-client
This class will be needed in the future to add Android-specific touch actions (as well as the IOS one).
Also, there is second very Java-specific reason. This class is a specific implementation of Builder pattern with inheritance. If you check the ancestor classes they all have quite specific generic signatures and this all is done to make builder methods return appropriate class without casting, for example:
new IOSTouchAction(driver).press(...).doubleTap(...)
won't work in the previous implementation, because press returns the instance of TouchAction class instead of IOSTouchAction, where this method is implemented, so it is necessary to perform class cast:
((IOSTouchAction)new IOSTouchAction(driver).press(...)).doubleTap(...)
This approach fixes it, but now Java prevents one from passing TouchAction as a generic parameter, so Supplier<TouchAction> won't work, but Supplier<IOSTouchAction> works as expected. https://stackoverflow.com/questions/21086417/builder-pattern-and-inheritance has more details.