In my program I use a lot of Strings and StringBuilders. I would like to get rid of the StringBuilder toString() method and use CharSequences throughout. However I need access to the indexOf method (which is available in both StringBuilder and String but not in other implementations). How might I implement an interface that will make this function visible?
Share
Well, you could do it reasonably easily by hardcoding tests for known types, and doing it “manually” otherwise:
This is pretty ugly in terms of hard-coding the types, but it’ll work.