You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2004/12/20 21:17:02 UTC

Re: [collections] Modify getter result

See LazyMap.
Stephen

----- Original Message ----- 
From: "Nentwig, Timo" <ti...@jamba-ag.de>
I'm not sure whether this can be done with commons-collections. 

I need to hook in a collection and return a default value when the
requested key does not exist in the collection. E.g.

Map currency = new HashMap()
{
{
put("DE", "EUR");
put("US", "USD");
}
};

And currency.get("XY") is supposed to return a default value (this may
require additional logic and e.g. may write to the logger that an yet
unsupported ISOCODE was requested).

Can this be done?

Kind regards
Timo

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org