Is there a way to determine if an object is an instance of a generic type?
public test(Object obj) { if (obj instanceof T) { ... }
If you don't want to pass Class type as a parameter as mentioned by Mark Peters, you can use the following code. Kudos to David O'Meara.
Class type = (Class) ((ParameterizedType) getClass().getGenericSuperclass()) .getActualTypeArguments()[0]; if (type.isInstance(obj)) { ... }