Support custom return types for executeCommand

JAVA-1561
Support custom return types for getIndexes

JAVA-1562