DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=30911>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=30911 Map that returns a defaul value if key is not present Summary: Map that returns a defaul value if key is not present Product: Commons Version: 3.2 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Collections AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] By definition if a map does not contain a determined key it returns null. But sometimes may be desirable that it returns a not-null value for not present keys. My propose is create a Decorated Map that extends org.apache.commons.collections.map.AbstractMapDecorator class. In constructor it receives the original Map and a default value to be returned is for a inexistent key. This class will override get() method like this: public Object get(Object key) { Object value = super.get(key); if(value == null) { value = this.defaultValue; } return value; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
