I'd like to run a static method on a parameterized type. Specifically, I have a class that is parameterized with an Enum. From within the class, I'd like to get to the Enum's values. Here's an example of what I'm trying to do.
The "public T values()" method won't compile. [ December 02, 2008: Message edited by: Max Rahder ]
Hello, i think that you cannot do that not in that way. Because you are trying to return the values of an erased type. When you are gonna execute the method values from the Test.class you're actually returning Object and the compiler insert a cast to Marx but inside the method you cannot know that type because of how erasure works.
This it's my approach to what you posted
You could substitute the Parameter T in a Child class of Test and that's the only way that i know, that the ParameterizedType can be inferred, like the example below:
[ December 02, 2008: Message edited by: Nitesh Kant ]
Joined: Nov 06, 2000
Thanks Angel, I think you're right. I'll do as you suggest and pass the enumeration class reference into the constructor, and save it for use in returning its values, as shown below. Thanks again!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com