Scala method where type of second parameter equals part of generic type from first parameter

Posted by ifischer on Stack Overflow See other posts from Stack Overflow or by ifischer
Published on 2010-06-18T10:04:07Z Indexed on 2010/06/18 10:13 UTC
Read the original article Hit count: 414

Filed under:
|

I want to create a specific generic method in Scala. It takes two parameters. The first is of the type of a generic Java Interface (it's from the JPA criteria query). It currently looks like this:

def genericFind(attribute:SingularAttribute[Person, _], value:Object) {
  ...
}

// The Java Interface which is the type of the first parameter in my find-method:
public interface SingularAttribute<X, T> extends Attribute<X, T>, Bindable<T>

Now i want to achieve the following: value is currently of type java.lang.Object. But I want to make it more specific. Value has to be the of the same type as the placeholder "_" from the first parameter (and so represents the "T" in the Java interface).

Is that somehow possible, and how?

BTW Sorry for the stupid question title (any suggestions?)

© Stack Overflow or respective owner

Related posts about scala

Related posts about scala-2.8