SamirTalwar / Rekord

Type-safe records in Java, to be used instead of POJOs, Java beans, maps or value objects.
47 stars 6 forks source link

Add option to allow to specify keys for sorting #6

Open jukecraft opened 8 years ago

jukecraft commented 8 years ago

It would be lovely to have the ability to specify which fields to use when sorting rekords - basically implementing the Comparable interface

SamirTalwar commented 8 years ago

Would it make more sense to preserve either insertion order or accepting construction order?

jukecraft commented 8 years ago

I'm not sure what you mean. My example is that I load a forecast (consisting of date and expectedValue) from the database and put it in a list, then transform it to the rekord object and return it in an API response. The forecasts should be sorted by date.

I currently use a Forecast object that overrides compareTo using the date, but I'd like to replace that with a rekord.

SamirTalwar commented 8 years ago

Ah, I see, makes sense. It would probably make sense to wrap it in a ComparableRekord. Will think about it.