I am writing a client wrapper for a service. Which have given client implementation. Having Two class hierarchy:
- Account
- Product
Both classes doesn't share common parent interface. But they while using them they have similar implementation:
Example of piece of code performing
Account service you need following steps of code:
final AccountsCustomBatchRequest content = new AccountsCustomBatchRequest();
content.setEntries(request);
final AccountsCustomBatchResponse response = this.service.accounts().custombatch(content).setDryRun(this.isDryRun)
.execute();
return response.getEntries();
Similar for product:
final ProductsCustomBatchRequest content = new ProductsCustomBatchRequest();
content.setEntries(request);
final ProductsCustomBatchResponse response = this.service.products().custombatch(content).setDryRun(this.isDryRun)
.execute();
return response.getEntries();
Is there a way to generalize the code? I can't use generic pattern as both those not support common parent class. Can I do like:
T extends Account or Product ?