Hi... I am relatively new to Java and object-oriented development. I've written the following Java / Groovy method which works correctly... I've been asked to convert this method into a property...
Code:
boolean sortedDescending(columnId) {
def doubleFormat = NumberFormat.instance
def originalList = txnTable.column(columnId).collect { it.text() }
def descendingSortedList = originalList.sort(false) { it ? -doubleFormat.parse(it) : Double.POSITIVE_INFINITY }
return (descendingSortedList == originalList)
}
Here is part of a class and my first incorrect attempt:
Code:
class TransactionTable extends Module {
boolean sortedDescending
void setSortedDescending(columnId) {
def doubleFormat = NumberFormat.instance
def originalList = txnTable.column(columnId).collect { it.text() }
def descendingSortedList = originalList.sort(false) { it ? -doubleFormat.parse(it) : Double.POSITIVE_INFINITY }
this.sortedDescending = (descendingSortedList == originalList)
}
If you have any tips on how I can convert the above method into a property that would be wonderful.
All I really want to do is set sortedDescending to be true or false based on the comparison:
descendingSortedList == originalList
... Rich