You can make everyone happy by completing all three. eg:.
data class User(val name: String) fun userSequence(): Sequence<User> = TODO() fun usersLazily(): Iterable<User> = userSequence().asIterable() fun userStream(): Stream<User> = userSequence().asStream()
By not using a simple name, such as users for any of these functions, you make the caller a little redundant for what they really want:
- Kotlin users will use
userSequence . - Java 1.6 and 1.7 users will use
usersLazily . - Java 1.8 users will use
userStream .
userStream must be defined in a separate JAR adding JDK 1.8 support for your 1.6 / 1.7 JAR (similar to how org.jetbrains.kotlin:kotlin-stdlib-jre8 does for org.jetbrains.kotlin:kotlin-stdlib ).
With that said, I would question if you really need to support Java 1.6 or 1.7 support. If you do not notice that you do not, you can put userSequence and userStream in the same JAR and not even define usersLazily .
mfulton26
source share