2010/11/15 Nicolas Lalevée <[email protected]>: > I saw that class EnumeratedAttribute, but it helps to define enums only from > the IntrospectionHelper. When I started to use that class, the strings > no-so-enum were still "leaked" through the Java API of the ProjectHelper.
Right. > So I implemented a class that behave like the Java 5 enums, where there is no > possibility at compile time to have any other value than the predefined ones. Right. Note that that if it was serializable, new instances would still be recreated by the framework, and would need to be replaced before the world could see them (using readReplace()). > Then on the IntrospectionHelper side, it still see a simple string. So the > code that checks the values is still in the implementation of the target > (well actually delegated with some error rethrowing). Which still leaves the door open for passing any string at the API level. But I agree that EnumeratedAttribute's string-based approach is not ideal either. > But maybe I should continue, make an EnumeratedAttribute which make the > bridge with the enum like class OnMissingExtensionPoint. But it won't save > much code. Yep. > I got an idea. What about creating an interface Enum which will be a marker > for classes which are expected to have a valueOf static method (like for > every enum in java 5), and have IntrospectionHelper support that ? I think > that it could be done easily in IntrospectionHelper#getEnumSetter . > WDYT ? Given that IH already handles java.lang.Enum, maybe it's too late to do this. Then again, Ant being JDK 1.4 based could use it. This is all nitpicking on my part already, so don't worry about it. What you have it fine. --DD --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
