bpiwowar.argparser
Class GenericHelper
java.lang.Object
bpiwowar.argparser.GenericHelper
public class GenericHelper
- extends Object
Helper methods for generics
- Author:
- bpiwowar
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenericHelper
public GenericHelper()
newArrayList
public static final <T> ArrayList<T> newArrayList()
newTreeMap
public static final <K,V> TreeMap<K,V> newTreeMap()
newHashMap
public static final <K,V> HashMap<K,V> newHashMap()
newHashSet
public static final <T> HashSet<T> newHashSet()
checkGenerics
public static boolean checkGenerics(Class<?> candidate,
Type gtype,
Class... classes)
- Check if the generic types of an implemented superclass/interface match
GenericHelper.checkGenerics(Collection.class, gtype, String.class);
- Parameters:
candidate
- gtype
- classes
-
- Returns:
getActualTypeArguments
public static Type[] getActualTypeArguments(Class<?> candidate,
Class<?> implemented)
- Reflection helper - give the generic parameters of a class.
- Parameters:
candidate
- The class implementing the superclass or superinterfaceimplemented
-
- Returns:
- a type array of the type arguments of a superclass or a
superinterface
newTreeSet
public static <T> TreeSet<T> newTreeSet()
newArrayList
public static <T> ArrayList<T> newArrayList(int length)
newArray
public static final <T,U extends T> U[] newArray(Class<T> theClass,
int length)
Copyright © 2013. All Rights Reserved.