Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: Re: [aspectj-users] Adding common methods for Enum

Hi Simone,
Yes I looked at the manual it says the it will consider implementing the method injection and exteding interface in future releases.
But as u mentioned the valueOf() return the current enum value only , we need to able to get enum from a string like u get the code from UI and want to load the enum on the bean.
The method i added here now i have to copy over all the enums just changing the names of the enum.So i thought it may be available from 1.6 ..I will  wait for this change:)
Thanks,
Vinodh 


On Thu, 31 Jul 2008 Simone Gianni wrote :
>Hi Vinodh,
>Unfortunately no, you cannot use AspectJ to inject methods in Enums, as
>is explained in AspectJ 5 manual at chapter 7. You can fill a request
>for an enhancement, or look if there is already one open and vote for
>it, in both cases adding your use case.
>
>Anyway, I'm pretty sure there is already a method called valueOf() that
>will convert the textual (String) name of an Enum to its corresponding
>constant.
>
>Simone
>
>
>vinodh subbiah wrote:
> >
> > 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
> >
> > Vinodh Subbiah,
> > 580 Laforet Street,Apt 14
> > Windsor N9C3G8
> > Canada
> > Ph 519-971-7847
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
>
>
>--
>Simone Gianni
>http://www.simonegianni.it/
>CEO Semeru s.r.l.
>Apache Committer
>
>_______________________________________________
>aspectj-users mailing list
>aspectj-users@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/aspectj-users

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

Citigold

Back to the top