user_1357
user_1357

Reputation: 7940

Make scala.Long Comparable

I have a following function which requires T to extend Comparable. scala.Long is not comparable as it is representing Java's primitive version.

    public static <T extends Comparable<? super T>> Combine<T> ordering() {}

Upvotes: 0

Views: 187

Answers (1)

Juan
Juan

Reputation: 5589

You could wrap your scala.Long in a Comparable wrapper, and use that class:

public static class ScalaLongWrapper implements Comparable<scala.Long>{
     public scala.Long v;

     public ScalaLongWrapper(scala.Long l){
         this.v = l;
     }

     public int compareTo(scala.Long l){
         return this.v - l;
     }
 }

Upvotes: 3

Related Questions