Class ImmutableConfigurationInvocationHandler
- All Implemented Interfaces:
InvocationHandler
A specialized InvocationHandler
implementation for supporting immutable configurations.
An instance of this class is constructed with a reference to a Configuration
object. All method invocations
(which stem from the ImmutableConfiguration
interface) are delegated to this object. That way all
functionality is actually backed by the underlying Configuration
implementation, but because the associated
proxy only implements the ImmutableConfiguration
interface manipulations are not possible.
There is one caveat however: Some methods of the ImmutableConfiguration
interface return an Iterator
object. Using the iterator's remove()
method it may be possible to remove keys from the underlying
Configuration
object. Therefore, in these cases a specialized Iterator
is returned which does not
support the remove operation.
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A specializedIterator
implementation which delegates to an underlying iterator, but does not support theremove()
method. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configuration
The underlying configuration object. -
Constructor Summary
ConstructorsConstructorDescriptionImmutableConfigurationInvocationHandler
(Configuration configuration) Creates a new instance ofImmutableConfigurationInvocationHandler
and initializes it with the wrapped configuration object. -
Method Summary
-
Field Details
-
wrappedConfiguration
The underlying configuration object.
-
-
Constructor Details
-
ImmutableConfigurationInvocationHandler
Creates a new instance ofImmutableConfigurationInvocationHandler
and initializes it with the wrapped configuration object.- Parameters:
configuration
- the wrappedConfiguration
(must not be null)- Throws:
NullPointerException
- if theConfiguration
is null
-
-
Method Details
-
invoke
This implementation delegates to the wrapped configuration object. Result objects are wrapped if necessary.- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
handleResult
Handles the result from the method invocation on the wrapped configuration. This implementation wraps result objects if necessary so that the underlying configuration cannot be manipulated.- Parameters:
result
- the result object- Returns:
- the processed result object
-