There is another complicated one: BeanComparator implements Comparator in a way that it compares a given property of a specific bean class. The actual comparison is handled by another Comparator stored in a member field.
So I am tempted to transform it to BeanComparator<T, P> where T is the bean class and P is the type of the property. The internal Comparator would then be of type <P>. However, this does not really work out for the following reasons: - The internal comparator can be passed to the constructor, but this is optional. If it is not defined, a helper class from [collections] is used providing a generic Comparator on Comparable objects. How can this be aligned to the type parameter? - The value of the property to be compared is obtained using PropertyUtils which returns an Object. So there is no chance for the compiler to do type checks. Perhaps we can check manually whether the value of the property is of the expected type, but this implies that we have to determine the class of the type parameter at runtime. AFAIK this is not always possible, e.g. if a subclass is created which does not have type parameters. Any ideas? Thanks Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
