public class Test
{
public static void main(String[] args)
{
Foo<String> foo = new Foo<String>();
foo.setBleh(LOLbject.New("Hello World"));
System.out.println(foo.getBleh());
foo.printBlehType();
}
}
class LOLbject<T>
{
private T t;
private final Class<T> type;
public LOLbject(final T t, final Class<T> type)
{
this.t = t;
this.type = type;
}
public Class<T> getType()
{
return type;
}
public T getValue()
{
return t;
}
public void setValue(final T value)
{
this.t = value;
}
public static LOLbject New(Object o)
{
return new LOLbject(o,o.getClass());
}
}
class Foo<T>
{
private LOLbject<T> bleh;
public void setBleh(LOLbject<T> value)
{
bleh = value;
}
public T getBleh()
{
return bleh.getValue();
}
public void printBlehType()
{
System.out.println(bleh.getType());
}
}