dumptruckman
02/12/2019, 5:39 PMdumptruckman
02/12/2019, 5:39 PMdumptruckman
02/12/2019, 5:40 PMCzar
02/12/2019, 5:41 PMhelp
protected
and foo
open
, otherwise it should be in foo
, like your first exampledumptruckman
02/12/2019, 5:43 PMSteve Ruben.
02/12/2019, 6:43 PMAndrew Gazelka
02/13/2019, 2:28 PMAny
) is such that Kotlin can not recognize it as a delegate. Any way I can fix this?
inline fun <reified T : Any> ConfigurationSection.tester(
basePath: String,
default: T,
crossinline accept: (T) -> Boolean = { true }
): Any {
return object {
operator fun getValue(thisRef: T, property: KProperty<*>): T {
val camelCase = property.name.hyphenate()
val path = "$basePath.$camelCase"
val res = this@tester[path]
return when (res) {
null, !is T, !accept(res) -> {
this@tester[path] = default
default
}
else -> res
}
}
}
}
karelpeeters
02/13/2019, 2:30 PMReadOnlyProperty
and return that type. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.properties/-read-only-property/index.htmlguppyfaced
02/13/2019, 4:46 PMHexa
02/13/2019, 5:03 PMException in thread "main" com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `Message` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (String)"{"message": "foo"}"; line: 1, column: 2]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1343)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1032)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1297)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3004)
at UserRestServiceKt.main(UserRestService.kt:8)
Hexa
02/13/2019, 5:03 PMimport com.fasterxml.jackson.databind.ObjectMapper
private val objectMapper = ObjectMapper()
fun main(args: Array<String>) {
val someJson: String = """{"message": "foo"}"""
val serialised = objectMapper.readValue(someJson, Message::class.java)
}
data class Message(val message: String)
M Jones
02/13/2019, 10:38 PMclass GreetingProvider(_greeting: String) {
val greeting = _greeting
}
class GreetingPrinter(private val _greetingProvider: GreetingProvider) {
fun printGreeting() = println(_greetingProvider.greeting)
}
fun main(args: Array<String>) {
val myBeans = beans {
bean { GreetingProvider("Hello, there!") }
bean { GreetingPrinter( ref<GreetingProvider>())}
}
val context = GenericApplicationContext()
val xmlReader = XmlBeanDefinitionReader(context)
xmlReader.loadBeanDefinitions(ClassPathResource("META-INF/some-context.xml"))
context.refresh()
}
elect
03/01/2019, 1:17 PMArray<*>::class
triggers the very same errorserebit
03/01/2019, 7:51 PMdimsuz
03/01/2019, 7:53 PMitnoles
03/01/2019, 7:55 PMdimsuz
03/01/2019, 7:57 PMitnoles
03/01/2019, 7:59 PMAndrew Gazelka
03/02/2019, 1:01 AMInt
and Long
(or likewise Float
and Double
) without repeating a bunch of code?SiebelsTim
03/02/2019, 12:25 PM@JvmField
on the x field might help. Can you try that and report back?popescustefanradu
03/03/2019, 9:21 AMpopescustefanradu
03/03/2019, 9:22 AMpopescustefanradu
03/03/2019, 9:22 AMkarelpeeters
03/03/2019, 9:23 AMval x: Class<MyType>
or KClass<MyType>
popescustefanradu
03/03/2019, 9:27 AMlateinit var valueSerializer: Class<Serializer<Any>>
Kris Elsinga
03/04/2019, 7:27 PMDavide Giuseppe Farella
03/05/2019, 3:01 AMefemoney
03/05/2019, 3:00 PMMarharyta Nedzelska
03/05/2019, 3:33 PMnickk
03/05/2019, 3:34 PM::ClassName
is a reference to the class constructor? Wrote it by accident, and seems handy…