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

Reply via email to