I have a class:
public class MultipleSorting<T extends Enum<?>> {
private T criteriaType;
public Class<T> getCriteriaClass() {
Field field = ReflectionUtils.getField(getClass(),"criteriaType");
ReflectionUtils.makeAccessible(field);
return (Class<T>)field.getType();
}
}
This class is get instantiated as:
public abstract class MultiSortPageableController<T extends MultiSortPageableController<?,?>, U extends Enum<?>> {
private MultipleSorting<U> multipleSorting;
public MultiSortPageableController() {
super();
multipleSorting = new MultipleSorting<U>();
}
}
The actual value of U
is passed from the child class of MultiSortPageableController
which is:
public abstract class AbstractArticleSearchController<T extends AbstractArticleSearchController<T>> extends MultiSortPageableController<T,ArticleSortField> {
}
The ArticleSortField
is an Enum
.
I was expecting the method getCriteriaClass
of MultipleSorting
would return ArticleSortField
from a method of MultiSortPageableController
. But it is returning java.lang.Enum
.
I am unable to figure it out why it is not returning the actual enum and how can I make it so. Any pointer would be very helpful to me. I need to get ArticleSortField
.
Purpose:
I two requirement:
- To get the actual class of enum type (say
ArticleSortField.class
) - To list enum value. If I have the enum class, then I could invoke
class..getEnumConstants()
.