| [aspectj-users] Adding common methods for Enum |
Hi All,
I have few enum defined in my project , but now i want to provide a common methods which will return the Enum for the values we pass as String.Like you pass the description and the Enum
For this we have a method
public static ServiceType getEnum(String name){
ServiceType serviceType = null;
for (ServiceType tempServiceType : ServiceType.values()) {
if( tempServiceType.getName().equalsIgnoreCase( name ) ){
serviceType = tempServiceType;
break;
}
}
if( serviceType == null ){
throw new IllegalArgumentException( "Invalid type: "+name );
}
return serviceType;
}
So instead of using this same code all over the Enum defined, can i use aspectJ to have this functionality?
Please help,
Regards,
Vinodh