Sylvain Wallez wrote:

> 
> Berin Loritsch a écrit :
> 
>>Vincent Massol wrote:
> 
> Agree with enforcing contracts, but IMHO it would be a safer construct
> to throw an IllegalStateException if the manager is already set instead
> of silently ignoring it.


You have a point.


> For this purpose, I have an ImmutablePropertyException (see attached
> file) that automates this check in one line. You just have to write :
> 
> public void Compose(ComponentManager manager)
> {
>   ImmutableProperyException.check(this.manager, manager, "Manager
> already set");
>   this.manager = manager;
> }
> 
> I'd be happy if this utility class could make its way into Avalon (but
> where : framework, excalibur ?)


Two questions:

Which exception does it throw?  guess: IllegalStateException()

Can we change the name?

We already have an ExceptionUtil in org.apache.avalon.framework.ExceptionUtil.
I would prefer adding a couple signatures:

/** two member version will set the first variable if not set, or throw exception */
ExceptionUtil.check(this.manager, manager, "Manager already set");

/** one member version used for state checking */
ExceptionUtil.check(this.isInitialized, "Component not initialized");




-- 

"Those who would trade liberty for
  temporary security deserve neither"
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to