com.hammurapi.convert

## Class Mixer

- java.lang.Object
- - com.hammurapi.convert.Mixer

-     public class Mixer
      extends Object

  Mixes interfaces from multiple objects into one proxy.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Mixer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Object` | `addInterceptors(Object master, Object... interceptors)` Creates a proxy which routes invocations to master unless one of interceptors has a method with matching signature.
    `static Object` | `combine(Object[] objects, Class<?>[] interfaces)` Creates a proxy which implements given interfaces and routes invocations to appropriate object.
    `static Object` | `mix(Object... objects)` Mixes interfaces from multiple objects into one proxy.
    `static Object` | `mixIn(Object object, Class<?>... interfaces)` Mixes-in implementation of interfaces into class.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Mixer

          public Mixer()

  - ### Method Detail

    - #### mixIn

          public static Object mixIn(Object object,
                     Class<?>... interfaces)

      Mixes-in implementation of interfaces into class. I.e. it creates a proxy which implements all object's interfaces plus interfaces from parameters. E.g. class has methods compatible with interfaces, but doesn't implement the interface itself. This is very similar to duck typing. This method doesn't check for method compatibility, it simply routes interface methods to the object. It is useful when only a sub-set of interface methods is used by the calling code, so the code would work even if strict conversion failed.
      Parameters:
        `object` -
        `interfaces` -
      Returns:

    - #### addInterceptors

          public static Object addInterceptors(Object master,
                               Object... interceptors)

      Creates a proxy which routes invocations to master unless one of interceptors has a method with matching signature. Only interface methods are routed to interceptors. Traditional approach to intercepting in Java is to create filters/wrappers. This approach might be problematic if the filter master instances might be of different subclasses of the base filtered type and if the subclassed functionality must be propagated through the filter. Returned proxy invokes only interceptor's method. It is responsiblity of the interceptor to call master's method if needed. Interceptor methods are matched to master methods based on name and parameter types equality (as in overriding). Return type and exception types are not taken in consideration.
      Parameters:
        `master` -
        `interceptors` -
      Returns:

    - #### combine

          public static Object combine(Object[] objects,
                       Class<?>[] interfaces)

      Creates a proxy which implements given interfaces and routes invocations to appropriate object. If object is not found for a particular interface, then invocation is routed to the first object.
      Parameters:
        `object` -
        `interfaces` -
      Returns:

    - #### mix

          public static Object mix(Object... objects)

      Mixes interfaces from multiple objects into one proxy. It can be used to "mix-in" interface into another interface, e.g. mix-in application-specific interfaces into HttpServletRequest. Different interfaces can be mixed-in depending on context, which is difficult to achieve with wrapping.
      Parameters:
        `objects` -
      Returns: