我想在Scala中创建一个特定的泛型方法。它需要两个参数。第一种是泛型Java接口(来自JPA条件查询)。现在看起来是这样的:
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>
现在我想实现以下目标:
价值
这有可能吗?怎么可能?
编辑:
添加了一个可以使问题更清楚的附加示例:
// A practical example how the Scala method could be called
// Java class:
public class Person_ {
public static volatile SingularAttribute<Person, Long> id;
}
// Calling the method from Scala:
genericFind(Person_.id, Long)