我的代码是:
public static <K, V> void initMapperJob( Job job,
Collection<WebPage.Field> fields, Class<K> outKeyClass, Class<V>
outValueClass, Class<? extends GoraMapper<String, WebPage, K, V>> mapperClass,
Class<? extends Partitioner<K, V>> partitionerClass, boolean reuseObjects)
throws ClassNotFoundException, IOException {
DataStore<String, WebPage> store = createWebStore(job.getConfiguration(), String.class, WebPage.class );
........
}
我改变如下:
public static <K, V, P extends PersistentBase, F extends Fields> void initMapperJob(Job job,
Collection<F> fields,
Class<K> outKeyClass, Class<V> outValueClass,
Class<? extends GoraMapper<String, P, K, V>> mapperClass,
Class<? extends Partitioner<K, V>> partitionerClass, boolean reuseObjects)
throws ClassNotFoundException, IOException {
DataStore<String, P> store = createWebStore(job.getConfiguration(),
String.class, P.class );
....
}
我的问题是:如何通过 java 为以下行设置泛型类?
DataStore store = createWebStore(job.getConfiguration(), String.class, P.class );
如果我设置为like(P.class或P),则发生错误。
调用以下方法。
public static <K, V extends Persistent> DataStore<K, V> createWebStore(Configuration conf,
Class<K> keyClass, Class<V> persistentClass){...}