Class ProxyBuilder<T>

  • Type Parameters:
    T - the type of the root object.

    public class ProxyBuilder<T>
    extends Object
    Allows an object to be wrapped by a proxy so that it will implement additional interfaces.
    • Constructor Detail

      • ProxyBuilder

        public ProxyBuilder()
    • Method Detail

      • withRoot

        public ProxyBuilder<T> withRoot​(T rootObject)
        Specifies the root object for the proxy that shall be enhanced.
        Parameters:
        rootObject - the root object.
        Returns:
        this builder for chaining.
      • withInterface

        public ProxyBuilder<T> withInterface​(Class<?> interfaceClass,
                                             Object interfaceImpl)
        Specifies an interfaces and an implementation of an interface by which the root object shall be extended.
        Parameters:
        interfaceClass - the class of the interface
        interfaceImpl - an implementation of the interface
        Returns:
        this builder for chaining.
      • build

        public T build()
                throws ProxyException
        Creates a proxy object out of the specified root object and the specified interfaces and implementations.
        Returns:
        a proxy object that is still of type T but additionally implements all specified interfaces.
        Throws:
        ProxyException - if the proxy could not be created.