Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How do you introduce a method on a Java5 enum?

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:matthew@xxxxxxxxxxxxxxx
skype:matthewadams12
yahoo:matthewadams
aol:matthewadams12
google-talk:matthewadams12@xxxxxxxxx
msn:matthew@xxxxxxxxxxxxxxx
http://matthewadams.me
http://www.linkedin.com/in/matthewadams


Back to the top