Say I have a method called as `.method(true)` or ...
# announcements
s
Say I have a method called as
.method(true)
or
.method(false)
. I would like to migrate that to
.method(SortOrder.ASC)
and
.method(SortOrder.DESC)
respectively. Can I do that with
@Deprecated
or something similar that can be triggered on an entire project? (I can easily end up with
.method(if(true) SortOrder.ASC else SortOrder.DESC)
but I would like to automate the final step)
c
I guess you could write something like:
Copy code
@Deprecated
fun method(thing: Boolean) { method(if (true) ASC else DESC) }
fun method(thing: SortedOrder) { ... }
This way your old code can continue calling the old function, and you can use the new code for everything else
1
n
I would add a companion method to
SortOrder
to keep the knowledge of
true == ASC
in a single place and then use
Copy code
@Deprecated("Use SortOrder")
fun method(asc: Boolean) {
    method(SortOrder.fromBoolean(asc))
}