 <p>You could just use the type T directly for a simple getter and <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#cast%28java.lang.Object%29" rel="nofollow">Class.cast</a> -method for other types:</p> <pre><code>public class GenericDataTest { private static class DataTest&lt;T&gt; { private T value; public DataTest(T value) { this.value = value; } public T getValue() { return value; } public Object getValueAsType(Class&lt;?&gt; type) { return type.cast(value); } } @Test public void testGeneric() { DataTest&lt;String&gt; stringTest = new DataTest&lt;String&gt;("Test"); Assert.assertEquals("Test", stringTest.getValue()); Assert.assertEquals("Test", stringTest.getValueAsType(String.class)); DataTest&lt;Double&gt; doubleTest = new DataTest&lt;Double&gt;(1.0); Assert.assertEquals(1.0, doubleTest.getValue()); Assert.assertEquals(1.0, doubleTest.getValueAsType(Double.class)); } @Test(expected = ClassCastException.class) public void testClassCastFailure() { DataTest&lt;String&gt; stringTest = new DataTest&lt;String&gt;("Test"); Assert.assertEquals("Test", stringTest.getValueAsType(Float.class)); } } </code></pre>