[ https://issues.apache.org/jira/browse/CONFIGURATION-654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15942338#comment-15942338 ]
Oliver Heger commented on CONFIGURATION-654: -------------------------------------------- Sounds like a reasonable enhancement. I like the variant which returns an Optional best, but unfortunately, [configuration] is still on Java 6 (we might go to 7 soon); so we will probably have to stick with a *null* return value. Any chance that you could provide a patch? > Add optionalConfigurationAt method to HierarchicalConfiguration > --------------------------------------------------------------- > > Key: CONFIGURATION-654 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-654 > Project: Commons Configuration > Issue Type: Improvement > Reporter: RafaĆ Figas > Labels: easyfix > > It would be nice to have method similar to configurationAt, but expecting > that there is one or no configuration at given key. > Currently there is no easy way to handle optional node in configuration. One > has to handle exception from configurationAt or use configurationsAt and do > various checks on collection size. > Method optionalConfigurationAt could return configuration at given key if > exactly one exists, return empty Optional or null, when there is no node, > exception when more then one node exists. > Method could throw exception like "UnexpectedMultipleNodesException' > containing key name, what would be helpful for clear error handling. > It would be very helpful while handling optional nodes. -- This message was sent by Atlassian JIRA (v6.3.15#6346)