Class AutoCloseableDelegateInvocationHandler

    • Constructor Detail

      • AutoCloseableDelegateInvocationHandler

        public AutoCloseableDelegateInvocationHandler​(Object proxyTarget,
                                                      AutoCloseable delegate)
    • Method Detail

      • getProxyTarget

        public Object getProxyTarget()
      • getAutoCloseableDelegate

        public AutoCloseable getAutoCloseableDelegate()
      • wrapDelegateCloseable

        public static <T extends AutoCloseable> T wrapDelegateCloseable​(Object proxyTarget,
                                                                        Class<T> type,
                                                                        AutoCloseable delegate)
        Wraps a target instance and an AutoCloseable delegate into a proxy instance that closes both when wrapper close method called.
        Type Parameters:
        T - The generic AutoCloseable wrapping interface
        Parameters:
        proxyTarget - The (never null) target instance - if not AutoCloseable then it's close() method will not be invoked (i.e., only the delegate)
        type - The target wrapping interface
        delegate - The (never null) delegate to close. Note: the delegate is closed after the target instance.
        Returns:
        The wrapping proxy
      • isCloseMethodInvocation

        public static boolean isCloseMethodInvocation​(Method m,
                                                      Object[] args)
      • isCloseMethod

        public static boolean isCloseMethod​(Method m)