java.lang.Object
dev.orne.config.impl.AbstractProxyHandler
dev.orne.config.impl.ConfigSubset
- All Implemented Interfaces:
InvocationHandler
Invocation handler for configuration subsets.
Invokes configuration methods adding the specified prefix
to configuration keys.
- Since:
- 1.0
- Version:
- 1.0, 2025-10
- Author:
- (w) Iker Hernaez
-
Field Summary
Fields inherited from class dev.orne.config.impl.AbstractProxyHandler
instance -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConfigSubset(Config instance, String prefix) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringasConfigKey(String key) Converts a property key of this sub-set to a delegated configuration key by adding the prefix.protected StringasSubsetKey(String key) Converts a delegated configuration key to a property key of this sub-set by removing the prefix.static ConfigCreates a new configuration proxy instance with the specified configuration.static MutableConfigcreate(MutableConfig config, String prefix) Creates a new configuration proxy instance with the specified configuration.static WatchableConfigcreate(WatchableConfig config, String prefix) Creates a new configuration proxy instance with the specified configuration.protected static <T extends Config>
Tcreate(ClassLoader classLoader, Class<T> type, T config, String prefix) Creates a new configuration proxy instance with the specified configuration.booleanprotected @Nullable EventsHandlerReturns the configuration change events handler.protected ConfigReturns the proxied configuration instance.protected @Nullable ObjectHandlesConfig.getKeys()andConfig.getKeys(String)andConfig.getKeys(Predicate)method invocations.protected StringReturns the prefix for configuration keys.protected @Nullable ObjecthandleConfigMethod(Config proxy, Method method, @Nullable Object[] args) HandlesConfigmethods invocations.protected @Nullable ObjecthandleMutableMethod(Method method, @Nullable Object[] args) HandlesMutableConfigmethods invocations.protected @Nullable ObjecthandleWatchableMethod(Method method, @Nullable Object[] args) HandlesWatchableConfigmethods invocations.inthashCode()@Nullable Objectprotected booleanisSubsetKey(String key) Checks if the specified configuration key belongs to this sub-set by checking the prefix.toString()Methods inherited from class dev.orne.config.impl.AbstractProxyHandler
handleObjectMethod, proxyEquals
-
Constructor Details
-
ConfigSubset
Creates a new instance.- Parameters:
instance- The configuration instance to be proxied.prefix- The prefix for configuration keys.
-
-
Method Details
-
create
Creates a new configuration proxy instance with the specified configuration.- Parameters:
config- The proxied configuration instance.prefix- The prefix for configuration keys.- Returns:
- A new configuration proxy instance.
-
create
Creates a new configuration proxy instance with the specified configuration.- Parameters:
config- The proxied configuration instance.prefix- The prefix for configuration keys.- Returns:
- A new configuration proxy instance.
-
create
Creates a new configuration proxy instance with the specified configuration.- Parameters:
config- The proxied configuration instance.prefix- The prefix for configuration keys.- Returns:
- A new configuration proxy instance.
-
create
protected static <T extends Config> T create(ClassLoader classLoader, Class<T> type, T config, String prefix) Creates a new configuration proxy instance with the specified configuration.- Type Parameters:
T- The configuration interface type.- Parameters:
classLoader- The class loader to be used for the proxy.type- The configuration interface type.config- The proxied configuration instance.prefix- The prefix for configuration keys.- Returns:
- A new configuration proxy instance.
-
getInstance
Returns the proxied configuration instance.- Returns:
- The proxied configuration instance.
-
getPrefix
Returns the prefix for configuration keys.- Returns:
- The prefix for configuration keys.
-
getEvents
Returns the configuration change events handler.- Returns:
- The configuration change events handler.
-
asConfigKey
Converts a property key of this sub-set to a delegated configuration key by adding the prefix.- Parameters:
key- The sub-set property key.- Returns:
- The delegated configuration key.
-
isSubsetKey
Checks if the specified configuration key belongs to this sub-set by checking the prefix.- Parameters:
key- The delegated configuration key.- Returns:
trueif the key belongs to this sub-set,falseotherwise.
-
asSubsetKey
Converts a delegated configuration key to a property key of this sub-set by removing the prefix.- Parameters:
key- The delegated configuration key.- Returns:
- The sub-set property key.
-
invoke
public @Nullable Object invoke(@Nullable Object proxy, Method method, @Nullable Object[] args) throws Throwable - Throws:
Throwable
-
handleConfigMethod
protected @Nullable Object handleConfigMethod(Config proxy, Method method, @Nullable Object[] args) throws ReflectiveOperationException HandlesConfigmethods invocations.- Parameters:
proxy- The proxy instance.method- The invoked method.args- The method arguments.- Returns:
- The method invocation result.
- Throws:
ReflectiveOperationException- If an error occurs during method invocation.
-
handleMutableMethod
protected @Nullable Object handleMutableMethod(Method method, @Nullable Object[] args) throws ReflectiveOperationException HandlesMutableConfigmethods invocations.- Parameters:
method- The invoked method.args- The method arguments.- Returns:
- The method invocation result.
- Throws:
ReflectiveOperationException- If an error occurs during method invocation.
-
handleWatchableMethod
protected @Nullable Object handleWatchableMethod(Method method, @Nullable Object[] args) throws ReflectiveOperationException HandlesWatchableConfigmethods invocations.- Parameters:
method- The invoked method.args- The method arguments.- Returns:
- The method invocation result.
- Throws:
ReflectiveOperationException- If an error occurs during method invocation.
-
getKeys
protected @Nullable Object getKeys(Method method, @Nullable Object[] args) throws ReflectiveOperationException HandlesConfig.getKeys()andConfig.getKeys(String)andConfig.getKeys(Predicate)method invocations.- Parameters:
method- The invoked method.args- The method arguments.- Returns:
- The method invocation result.
- Throws:
ReflectiveOperationException- If an error occurs during method invocation.
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractProxyHandler
-
equals
- Overrides:
equalsin classAbstractProxyHandler
-
toString
-