Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

AW: Enums Support

Jan Materne

2010-04-12


Author LoginPost Reply
Enumerations are only supported when writing tasks.
For Java <5 you extend EnumeratedAttribute. Its main method (abstract in EA) returns the list of possible values (getValues() is its name I think).
With Java5+ you could use Java enums directly.

There is no enum in properties (inside the buildfile).
  <property name="stage" enum="dev|test|prod"/>
  <property file="..."/> <!-- stage=dev => ok  stage=foo => build exception -->

When asking for input the task supports asking for specified values
  <input addproperty="stage" validargs="dev,test,prod"/>


Jan


> -----Ursprüngliche Nachricht-----
> Von: Antoine Levy Lambert [mailto:antoine@(protected)]
> Gesendet: Freitag, 9. April 2010 22:38
> An: Ant Users List
> Betreff: Re: Enums Support
>
> Raja Nagendra Kumar wrote:
> > Hi,
> >
> > Is it possible to define a property which takes only X,Y, Z
> values.. and
> > nothing more.. If any other thing is set for that
> property.. ant should give
> > the error.
> >
> > Sort of Enums in Java.. so that any wrong setting would
> result in compiler
> > error.
> >
> > Regards,
> > Nagendra
> >
> >
> >
> >
> >  
> Ant has a class called EnumeratedAttribute [out of the top of
> my head].
> There are no enumerated properties, but this is conceivable.
>
> You can try to write your own extension of the property task.
> I am not
> sure whether there would be a consensus among committers to add this
> function to ant-core ?
>
> Regards,
>
> Antoine
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.