Oliver Heger wrote:
The getSource() method was added on behalf of CONFIGURATION-215 [1].
The original request was a bit adapted to come to a more generic
solution. IIRC the usage scenario was that you have multiple child
configurations with different name spaces and want to uniquely
identify the child configuration that added a specific key. If
multiple child configurations define the key in question, no unique
source can be identified; hence the exception.
Do you propose making findSourceConfiguration() protected? I did not
do this in the past because I was not sure whether there would be
another use case for this method and I wanted to keep the API lean.
But if you need it, I am not against this change.
No, I wouldn't necessarily make it protected. It would be a bad idea to
have some classes have the method behave in one manner while in another
it behaves differently.
I ran into this problem because my use cases involve a combined
configuration where all the defaults are in the base configuration and
the first configuration contains values that override the defaults. I
was simply trying to write a unit test that listed the source for each
key to verify my new class was working properly.
I don't want to distract things by going into the details of this (I'll
do that when I submit the code), but in this case getSource seems to be
completely useless as it throws an exception for every key that is
defined in the override file. For the purposes you are suggesting a
better method name would have been getUniqueSource(). For my purposes
adding a getFirstSource() method would make sense. This would never
throw an exception but would either return the first configuration
containing the key or would return null. The only question would be what
to do about Lists. In all my use cases I will be disabling this behavior
as I never want to combine the data from multiple configurations.
Ralph
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]