the case is - that copy is very good for mutation ...
# announcements
m
the case is - that copy is very good for mutation and i want to make some kind of aspect for my pojos with interface so
Copy code
interface Archievable {
    val status: ArchievedStatus
}
enum class ArchievedStatus { NEW, READY,ARCHIVED}
 ///and then
data calss User(val blabla, override val status: ArchievedStatus): Archievable 
data calss Company(val blabla, override val status: ArchievedStatus): Archievable 
///with definition of archiving i wan't to create single method that use copy method and work with 2 pojos
and don't want lose
copy
form data class but use it to update entities
k
I'm afraid that's not possible, you can work around it by having another function
readCopy()
in the interface and implement that in every data class by just calling the generated
copy()
one.
Obviously try to find a better name for it.
m
override fun archiving(): PojoA = this.copy(status = ArchievedStatus.ARCHIVED)
just make this function as implementation of
fun archiving(): Archievable
tnx for your replies
maybe this case can be feature for kotlin? what do you think
k
It quite awkward really, having autogenerated functions implement interfaces.
Because there's no reason to think they'll conform to the contracts.