Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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;
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,

Vinodh Subbiah,
580 Laforet Street,Apt 14
Windsor N9C3G8
Ph 519-971-7847

Back to the top