I have an interface
public interface FooBar { }
I have a class that implements it
public class BarFoo implements Foo
Try something like the following:
Class thisClass = null;
Type type = getClass().getGenericSuperclass();
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type[] typeArguments = parameterizedType.getActualTypeArguments();
thisClass = (Class) typeArguments[0];
}