Class ConfigProxy<T>
java.lang.Object
tech.guilhermekaua.spigotboot.config.proxy.ConfigProxy<T>
- Type Parameters:
T- the config type
- All Implemented Interfaces:
MethodInterceptor
A proxy that intercepts all method calls on a config class and delegates to
the current config instance from
ConfigRef.get().
This ensures that injected config instances always return fresh values after reload,
without requiring developers to use ConfigRef<T>.get() explicitly.
Important: Config classes must have all fields private to ensure proper proxying. Direct field access bypasses the proxy and will return stale/default values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcreateProxy(@NotNull Class<T> configClass, @NotNull ConfigRef<T> configRef) Creates a proxy for the given config class that delegates all method calls to the current config instance from the ConfigRef.
-
Method Details
-
createProxy
@NotNull public static <T> T createProxy(@NotNull @NotNull Class<T> configClass, @NotNull @NotNull ConfigRef<T> configRef) Creates a proxy for the given config class that delegates all method calls to the current config instance from the ConfigRef.- Type Parameters:
T- the config type- Parameters:
configClass- the config class to proxyconfigRef- the config ref providing the current instance- Returns:
- a proxy instance that appears as the config class
- Throws:
ConfigException- if proxy creation fails
-
invoke
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable - Specified by:
invokein interfaceMethodInterceptor- Throws:
Throwable
-