arrow icon indicating copy to clipboard operation
arrow copied to clipboard

Support for "ComparisonChain"

Open rafakob opened this issue 9 years ago • 4 comments

Hi, great job, sir! :) I often include Guava in my projects, but I always end up using like 1% of it (mostly collections and predicates). The problem on Android is it's huge methods footprint, which I guess your lib is trying to solve.

I have only one request. Could you add class ComparisonChain? It has almost none dependencies, shouldn't be a problem :)

rafakob avatar Feb 23 '16 12:02 rafakob

Hey @rafakob thanks for the input here. I do wanna carefully pick what to add to the library since It might loose its main feature which is to stay tiny :). (I do not wanna end up with a big library)

Could you provide more context/information or use cases? Specially for android.

android10 avatar Feb 23 '16 21:02 android10

You meant use cases of other parts of Guava or just that ComparisonChain?

I like to use it with Ordering class, eg:

private List<User> orderData (List <User>list) {
    return new Ordering<User>() {
        @Override
        public int compare(User left, User right) {
            return ComparisonChain.start()
                    .compare(left.age(), right.age())
                    .compare(left.getLastname(), right.getLastname())
                    .compare(left.getFirstname(), right.getFirstname())
                    .result();
        }
    }.sortedCopy(list);
}

rafakob avatar Feb 24 '16 08:02 rafakob

@rafakob +1

Rainer-Lang avatar Feb 24 '16 09:02 Rainer-Lang

Will keep this in mind and label it as a feature request.

android10 avatar Mar 01 '16 22:03 android10