Class DuckTypeProxyFactory

java.lang.Object
com.atlassian.jira.util.DuckTypeProxyFactory

public class DuckTypeProxyFactory extends Object
Use this Factory to produce "Duck Type" proxies of a given interface with a delegate object that "implements" a subset of the interface methods. invalid input: '<'p
Since:
v6.4
  • Constructor Details

    • DuckTypeProxyFactory

      public DuckTypeProxyFactory()
  • Method Details

    • newStrictProxyInstance

      public static <T> T newStrictProxyInstance(Class<T> proxyInterface, Object delegate)
      Creates a new Proxy instance for the given interface.

      If any methods are called on the interface that are not defined in the delegate, then it will throw UnsupportedOperationException.

      Type Parameters:
      T - Type of the interface
      Parameters:
      proxyInterface - the interface to create a proxy for.
      delegate - the object to delegate to for implementations (quacks like a duck)
      Returns:
      a new Proxy instance for the given interface.
    • newLooseProxyInstance

      public static <T> T newLooseProxyInstance(Class<T> proxyInterface, Object delegate)
      Creates a new Proxy instance for the given interface.

      If any methods are called on the interface that are not defined in the delegate, then it will return null.

      Type Parameters:
      T - Type of the interface
      Parameters:
      proxyInterface - the interface to create a proxy for.
      delegate - the object to delegate to for implementations (quacks like a duck)
      Returns:
      a new Proxy instance for the given interface.