Scala method where type of second parameter equals part of generic type from first parameter
- by ifischer
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?)