tl;dr: Should I avoid exposing third-party types in a public interface?
I'm working on a Kotlin-based project that relies heavily on data keyed with two values. It's just something I'm tinkering with at the moment to learn Kotlin, but I've been considering publishing it to a public repository such as Maven Central.
In pure Java I might store this data in a Map<Foo, Map<Bar, Baz>> so that, given a Foo and a Bar, I might access it like so:
Baz someBaz = someData.get(someFoo).get(someBar)
In Kotlin, I can use
val someBaz = someObject[someFoo][someBar]
to the same effect, which is (slightly) cleaner. Instead, I opted to leverage the Table class in Guava* since it stores data in exactly this fashion and is considerably easier to work with.
Given that I may be publishing this project in a public fashion, should I expose (in public methods) references to the Guava Table class, or should I wrap them with an equivalent pure-Java (or Kotlin) API?
For example, should I do this (Option 1):
fun doSomeProcessing(data: Table<Foo, Bar, Baz>): Table<Foo, Bar, Baz>
and simply consume and produce a Table directly, or should I do this (Option 2):
fun doSomeProcessing(data: Map<Foo, Map<Bar, Baz>>): Map<Foo, Map<Bar, Baz>>
and then wrap the Map<Foo, Map<Bar, Baz>> in a Table?
Should I just operate on the Map directly, and forget about using Table* (Option 3)?
My gut says that Option 1 isn't a good idea, because I'm directly exposing a third-party API that users of the project might not (probably won't?) be interested in using.
On the other hand, Option 2 feels like a pointless obfuscation; if I'm really operating on a Table, I should just call it a Table and stop messing around with wrapping it in a recursive Map.
Option 3 just seems... wrong. I'm already using Guava and it exposes a very useful API that has exactly the sort of data structure I want to use, and I don't want to reinvent and reimplement a bunch of Guava code*.
*Note that this isn't the only reason I'm depending on Guava, and I'd have to change a non-trivial amount of code and reimplement a significant amount of functionality to do away with it entirely. So it's an option, but not one I'd be very happy to take.