Here you can find the source of getCollectionClass(TT tt)
Parameter | Description |
---|---|
tt | a parameter |
public static <TT> Class<Collection<TT>> getCollectionClass(TT tt)
//package com.java2s; import java.util.Collection; public class Main { /**/*from w ww. j a v a2 s . com*/ * This function helps avoid compile warnings by just having the warning here. * @param tt * @return Collection.class cast as having a type parameter */ public static <TT> Class<Collection<TT>> getCollectionClass(TT tt) { return (Class<Collection<TT>>) Collection.class.asSubclass(Collection.class); // Collection<TT> coll = new ArrayList< TT >(); // Class< Collection<TT> > ccls = (Class< Collection<TT> >)coll.getClass(); // return ccls; } /** * This function helps avoid compile warnings by just having the warning here. * @param ttcls * @return Collection.class cast as having a type parameter */ public static <TT> Class<Collection<TT>> getCollectionClass(Class<TT> ttcls) { return (Class<Collection<TT>>) Collection.class.asSubclass(Collection.class); // Collection<TT> coll = new ArrayList< TT >(); // //Class< Collection<TT> > ccls = (Class< Collection<TT> >)coll.getClass(); // Class< Collection<TT> > ccls = (Class< Collection<TT> >)coll.getClass().asSubclass( Collection.class ); // return ccls; } }