i have a data class with a lot of properties. I ne...
# announcements
j
i have a data class with a lot of properties. I need to create that class from java code, but I don't want to pass 800 nulls in the ctor. is there a cleaner way around that? @JvmOverloads doesn't seem to like data classes
s
can you clarify what problem you’re running into with
@JvmOverloads
and data classes?
j
@JvmOverloads can't be applied to a class.. and...
ooh... maybe i'm an idiot and just need to change how i'm defining the ctor... one moment
yes. I'm an idiot: data class ItemModel @JvmOverloads constructor(
sorry for the noise 🙂
oh... well...
ItemModel model = new ItemModel(); Error:(33, 35) java: constructor ItemModel in class ItemModel cannot be applied to given types; required: java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String found: no arguments reason: actual and formal argument lists differ in length
s
That’s odd
j
i think i figured it out, and it still centers around me being an idiot. If I provide default values in the ctor, javac is happy 🙂
s
Ahh, yep, that’d do it
No worries, we all need to rubber duck every now and again lol
j
i think i should avoid operating heavy machinery or motor vehicles for a while 😛
haha. yeah, but I try to limit those to truly hard questions 😛
s
😛 I won’t make any judgment there for you, but I will say I don’t mind giving folks small hints if they’re actively thinking about their problem
j
👍
thanks for the sanity check, btw 🙂
👍 1