apatrida
05/23/2017, 2:05 AMapatrida
05/23/2017, 2:05 AMapatrida
05/23/2017, 2:05 AMarmaxis
05/23/2017, 2:06 AM//in foo.java
@Nullable private List<String> getIds() {...}
ViewportInfo info = new ViewportInfo(100, 200, getIds());
armaxis
05/23/2017, 2:06 AMapatrida
05/23/2017, 2:06 AMclass ViewportInfo(channels: List<String>? = null, val startTime: Long, val duration: Long) {
val channelIds: List<String> = channels ?: emptyList()
}
apatrida
05/23/2017, 2:06 AMapatrida
05/23/2017, 2:07 AMarmaxis
05/23/2017, 2:08 AMarmaxis
05/23/2017, 2:08 AMapatrida
05/23/2017, 2:09 AMapatrida
05/23/2017, 2:09 AMdata class ViewportInfo private constructor (val channelIds: List<String>, val startTime: Long, val duration: Long) {
companion object {
@JvmStatic fun create(channelIds: List<String>?, startTime: Long, duration: Long): ViewportInfo {
return ViewportInfo(channelIds ?: emptyList(), startTime, duration)
}
}
}
// from java:
ViewportInfo something = ViewportInfo.create(null, 10, 1);
apatrida
05/23/2017, 2:10 AMapatrida
05/23/2017, 2:10 AMapatrida
05/23/2017, 2:11 AMdata class ViewportInfo (private val rawChannelIds: List<String>?, val startTime: Long, val duration: Long) {
val channelIds: List<String> = rawChannelIds ?: emptyList()
}
apatrida
05/23/2017, 2:11 AMvar
seems really bad.apatrida
05/23/2017, 2:11 AMarmaxis
05/23/2017, 2:12 AMapatrida
05/23/2017, 2:12 AMapatrida
05/23/2017, 2:13 AMapatrida
05/23/2017, 2:13 AMapatrida
05/23/2017, 2:13 AMarmaxis
05/23/2017, 2:14 AMarmaxis
05/23/2017, 2:14 AMdata class ViewportInfo (val channelIds: List<String>, val startTime: Long, val duration: Long)
armaxis
05/23/2017, 2:15 AMnull
apatrida
05/23/2017, 2:15 AMapatrida
05/23/2017, 2:15 AMapatrida
05/23/2017, 2:16 AMarmaxis
05/23/2017, 2:16 AMvar
- that actually brought up a problem on java side, I'm looking into right nowapatrida
05/23/2017, 2:16 AMvar
needs a reason to be var
otherwise pick val
always