Ok, fair enough. My only desire at this point was to add the getName() method to support Dozer marshalling, since it knows Java property conventions, and the Enum method name() doesn't abide by them. As it is, I have to manually write the getName() method on any Enum I define that needs to be marshalled, or figure out how to configure Dozer to use name() instead of getName() (which is probably not too hard, but I'm lazy).
It seems as though the introduction of an interface on an Enum should be ok, since an Enum can implement an interface. Since I haven't had the need yet, it's fine. Thanks! On Thu, Oct 1, 2009 at 3:10 PM, Andy Clement <[email protected]> wrote: > Hi Matthew, > > Unfortunately that is not allowed. Per the developers notebook ( > http://www.eclipse.org/aspectj/doc/released/adk15notebook/enums-in-aspectj5.html > ): > > * You cannot use declare parents to change the super type of an enum. > * You cannot use declare parents to declare java.lang.Enum as the > parent of any type. > * You cannot make inter-type constructor declarations on an enum. > * You cannot extend the set of values in an enum via any ITD-like > construct. > * You cannot make inter-type method or field declarations on an enum. > * You cannot use declare parents to make an enum type implement an > interface. > > But as it also says on that page: > "In theory, the last of these two items could be supported. However, > AspectJ 5 follows the simple rule that an enum type cannot be the > target of an inter-type declaration or declare parents statement. This > position may be relaxed in a future version of AspectJ." > > We just haven't had many users requesting that feature, so no work has > been done on it. > > cheers, > Andy. > > > 2009/10/1 Matthew Adams <[email protected]>: >> I want to add a method to all enums with the signature "String getName()". >> >> Any ideas? >> >> This doesn't appear to work: >> >> public aspect GetNameEnumIntroduction { >> >> interface Introduced { String name(); } >> >> declare parents : (Enum+) implements Introduced; >> >> public String Introduced.getName() { >> return this.name(); >> } >> } >> >> It also doesn't work if I change the type expression of declare >> parents to (Enum<? extends Enum>+). >> >> Thanks, >> Matthew >> >> -- >> mailto:[email protected] >> skype:matthewadams12 >> yahoo:matthewadams >> aol:matthewadams12 >> google-talk:[email protected] >> msn:[email protected] >> http://matthewadams.me >> http://www.linkedin.com/in/matthewadams >> _______________________________________________ >> aspectj-users mailing list >> [email protected] >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > -- mailto:[email protected] skype:matthewadams12 yahoo:matthewadams aol:matthewadams12 google-talk:[email protected] msn:[email protected] http://matthewadams.me http://www.linkedin.com/in/matthewadams _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
