[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: VersionImpl is not correct.

adrian@jboss.org do-not-reply at jboss.com
Tue Feb 5 13:34:22 EST 2008


"alesj" wrote : 
  | If you let any Version type to be present in our VersionRange, then you would have to let version be Object, which is a lot less type safe than our Version approach with comparators and thin wrappers present.
  | 

You read my mind. That is the approach I'm taking. i.e. I've removed the Version
interface altogether and just use an Object in its place in the spi.

I originally tried Comparable but that was redundant and messy since we don't really
use the compareTo() directly except when when comparing versions 
of the same type (and even then that's not really a requirement ;-).

I'm also adding a default String <-> Version comparator
so in prinicple you could just a String as your version.
But this isn't as efficient since potentially it has to parse the String ever
time it wants to compare it, e.g. probably twice to do a VersionRange check.

What this does mean is that there is no VersionImpl in what is now a public spi.
There is just our Version class that can be compared to other version classes
(including Strings :-) using the VersionComparators.

P.S. The hashCode() problem is unsolvable. So it is probably best to just
document that "versions" (and anything that uses a "version" in its identity) 
should be stored in Sorted Sets and Maps using a comparator based
on the VersionComparatorRegistry NOT the hashed collections.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126688#4126688

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126688



More information about the jboss-dev-forums mailing list