public abstract class Generic<C>
extends java.lang.Object
abstract class IKnowMyType<T> {
Generic<T> type = new Generic<T>(getClass()) {};
}
new IKnowMyType<String>() {}.type.resolve(); // String
Resolution happens lazily, upon resolve() invocation, by traversing the class hierarchy via reflection. Since it's a relatively heavy operation, it's performed only once; subsequent calls return the cached result.
| Modifier | Constructor and Description |
|---|---|
protected |
Generic(java.lang.Class<?> context) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object that) |
int |
hashCode() |
java.lang.Class<? super C> |
resolve() |
public java.lang.Class<? super C> resolve()
public boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object