/** * Returns the ModificationProxy invocation handler for an proxy object. * * <p>This method will return null in the case where the object is not a proxy, or it is being * proxies by another invocation handler. */ public static ModificationProxy handler(Object object) { return ProxyUtils.handler(object, ModificationProxy.class); }
/** * Unwraps a proxy returning the underlying object, if one exists. * * <p>This method handles two cases, the first is the case of a {@link WrappingProxy} in which * the underlying proxy object is returned.. The second is the {@link ProxyList} case in which * the underlying list is returned. * * @param object The proxy object. * @param handlerClass The invocation handler class. * @return The underlying proxied object, or the object passed in if no underlying object is * recognized. */ public static <T> T unwrap(T object, Class<? extends InvocationHandler> handlerClass) { if (object instanceof Proxy) { InvocationHandler h = handler(object, handlerClass); if (h != null && h instanceof WrappingProxy) { return (T) ((WrappingProxy) h).getProxyObject(); } } if (object instanceof ProxyList) { return (T) ((ProxyList) object).proxyList; } return object; }
ResolvingProxy rp = ProxyUtils.handler(result, ResolvingProxy.class);