natpryce
01/21/2019, 9:27 AMAndrew S
01/21/2019, 9:30 AMnatpryce
01/21/2019, 9:38 AMLeoColman
01/21/2019, 12:00 PMkotlin.experimental
compiler option?Czar
12/14/2019, 12:59 PM@Column
@Type(type = "org.hibernate.type.TextType")
val myText: String
So currently I have:
object Types {
const val TEXT_TYPE = "org.hibernate.type.TextType"
// other types
}
Is there a better way? I mean this is better than using the literals everywhere, but the source of the type is still a literal and I can't change this into:
const val TEXT_TYPE = TextType.INSTANCE.name
because then Kotlin complains that annotation value is not a compile time constant.
Any solution?Vinicius Carvalho
12/15/2019, 1:00 AMVinicius Carvalho
12/15/2019, 1:01 AMinterface Scrapper<T : Any>
abstract class AbstractSiteScrapper<T: Any> : Scrapper<T>
class SiteScrapper<Site>
class PageScrapper<Page>
Vinicius Carvalho
12/15/2019, 1:02 AMmutableMapOf<Class<*>, AbstractSiteScrapper<*>
Vinicius Carvalho
12/15/2019, 1:02 AMVinicius Carvalho
12/15/2019, 1:03 AMpage: Nothing
Vinicius Carvalho
12/15/2019, 1:04 AMinterface Scraper<T : Any> {
fun visit(page: T)
fun accept(value: Any) : Boolean
}
Vinicius Carvalho
12/15/2019, 1:04 AMVinicius Carvalho
12/15/2019, 1:06 AMval payload = queue.take()
val scraper = scrapers[payload::class.java]
scraper?.visit(payload)
Vinicius Carvalho
12/15/2019, 1:06 AMVinicius Carvalho
12/15/2019, 1:07 AMAbstractSiteScraper<Any>
fails because it says SiteScraper
is not the same type as AbstractSiteScraper<Any>
Vinicius Carvalho
12/15/2019, 1:07 AMVinicius Carvalho
12/15/2019, 1:09 AMval scrapers = mutableMapOf<Class<*>, AbstractSiteScraper<Any>>()
scrapers[Site::class.java] = SiteScraper() as AbstractSiteScraper<Any>
scrapers[Page::class.java] = PageScraper() as AbstractSiteScraper<Any>
Vinicius Carvalho
12/15/2019, 1:09 AMNikky
12/15/2019, 9:17 AMwhen
only works when the selaed class type is casted to outside
broken: https://i.imgur.com/tUusyIE.png▾
val reducer: Reducer<MultiplayerState> = { state, action ->
action as Actions
when(action) {
is Actions.AddObserver -> {
state.copy(observers = state.observers + action.observer)
}
is Actions.RemoveObserver -> {
state.copy(observers = state.observers - action.observer)
}
is Actions.SetConnectionState -> TODO()
}.exhaustive
}
Ashutosh Panda
12/15/2019, 12:23 PMAshutosh Panda
12/15/2019, 12:25 PMsteenooo
12/16/2019, 8:50 AMMadera Jan
12/16/2019, 12:58 PMbjonnh
12/16/2019, 6:12 PMMaciej Grzeszczak
12/16/2019, 7:40 PMephemient
12/16/2019, 7:47 PMcommanderpepper
12/16/2019, 7:51 PMjef
12/16/2019, 8:06 PMalexsimo
12/17/2019, 10:30 AMShootingStar
12/17/2019, 1:04 PMA better way to handle this situation is to use the safe call operator (?.). Safe call short-circuits