intercom-java
intercom-java copied to clipboard
Make TypedData Public to make creating utility functions for API access possible
Version info
- intercom-java version: 2.8.0
- Java version: 8
Description
While building an application that utilizes this library, it's a common use-case to want to access multiple APIs and share common code between the individual accessors. Each API object currently extends from TypedData
, which is great and totally makes sense, however TypedData
is currently package-private. What this means is that if we wanted to handle, for example, scrolling through User
and Contact
the same way, we cannot write a common utility function to handle this without jumping through a few hoops. I would suggest that it would be a good idea to make TypedData
public to open this path up.
Now, I of course understand the desire to keep TypedData
package-private since you are building a library and you want to restrict the children of this class to your library only. That definitely makes sense, but I don't feel like much, if anything, is lost by opening the visibility up. I understand if the answer is a simple "No, we won't do this", but it would definitely help clean some code up.
Example
Take this Kotlin snippet:
private fun <T : TypedData> ScrollableTypedDataCollection<T>.forEach(handler: (T) -> Unit) {
val data = getPage()
if (data.isNullOrEmpty()) {
return
}
data.forEach(handler)
scroll()
}
Of course this does not compile because TypedData
is not public.