FileDocCategorySizeDatePackage
DuckTypingDispatcher.javaAPI DocAndroid 5.1 API2099Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.dispatch

DuckTypingDispatcher

public class DuckTypingDispatcher extends Object implements Dispatchable
Duck typing dispatcher; converts dispatch methods calls from one class to another by looking up equivalently methods at runtime by name.

For example, if two types have identical method names and arguments, but are not subclasses/subinterfaces of each other, this dispatcher will allow calls to be made from one type to the other.

param
source dispatch type, whose methods with {@link #dispatch} will be called
param
destination dispatch type, methods will be converted to the class of {@code T}

Fields Summary
private final MethodNameInvoker
mDuck
Constructors Summary
public DuckTypingDispatcher(Dispatchable target, Class targetClass)
Create a new duck typing dispatcher.

param
target destination dispatch type, methods will be redirected to this dispatcher
param
targetClass destination dispatch class, methods will be converted to this class's

        checkNotNull(targetClass, "targetClass must not be null");
        checkNotNull(target, "target must not be null");

        mDuck = new MethodNameInvoker<T>(target, targetClass);
    
Methods Summary
public java.lang.Objectdispatch(java.lang.reflect.Method method, java.lang.Object[] args)

        return mDuck.invoke(method.getName(), args);