sure,

anywhere where u want to store objects and where u might not want to allow the 
addition of "same" objects such as in registries, caches, collections.

often they are underpinned with internal sets or maps and at times it is better 
to signal the client the hard way (ie. via a proper exception) that the object 
he intended to add already exists.

the reason i want to have a distinct exception here, is to allow the client to 
catch this case as opposed to the case where he might want to add an object who 
doest meet some constraints and where i then throw a "normal" Illegal Argument 
Exception.

Also, there is sometimes the case that i will not add the object/key itself but 
rather a base form that is then first converted into the real key/object.

such an exception would allow to return the derived key/object in a distinct 
way.
e.g

1. 
Regsitry.put(String url, Object){
 put(new Url(url, Object))
};

2. 
Regsitry.put(Url url, Object);


the implementation could throw a new ObjectExistException<Url>(url) in the 2nd 
method and the client could get the id from T getObjectKey() and do some fall 
back work noit having had the need to ever convert the string url himself into 
an Url Object.


hope that helps


-------- Original-Nachricht --------
> Datum: Fri, 11 Feb 2011 15:01:32 +0100
> Von: Simone Tripodi <simonetrip...@apache.org>
> An: Commons Developers List <dev@commons.apache.org>
> Betreff: Re: [lang] propse new ObjectExistsException extends 
> IllegalArgumentException

> Hi Thomas,
> can you describe please in which non-JPA context the exception can
> become useful?
> Many thanks in advance, have a nice day,
> Simo
> 
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
> 
> 
> 
> On Fri, Feb 11, 2011 at 10:31 AM, thomas menzel <dev.tom.men...@gmx.net>
> wrote:
> > hi,
> >
> > i suggest a new exception under the commons.lang.exception namely
> >
> > ObjectExistsException extends IllegalArgumentException.
> >
> > in the jpa world there is already one like this, bit i think it has
> merit for also other cases outside of jpa and hence i would like to see it
> defined in apache's commons.lang.exception.
> >
> > what do u think?
> >
> > --
> > NEU: FreePhone - kostenlos mobil telefonieren und surfen!
> > Jetzt informieren: http://www.gmx.net/de/go/freephone
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> > For additional commands, e-mail: dev-h...@commons.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
> 

-- 
Schon gehört? GMX hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://www.gmx.net/de/go/toolbar

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to